mdj Posted January 24, 2015 Share Posted January 24, 2015 function VolSerialNumber(DriveChar: Char): DWORD; unsafe;varNotUsed: DWORD;VolFlags: DWORD;VolSerNumber: DWORD;Buf: array [0..MAX_PATH] of Char;beginGetVolumeInformation ((PChar(DriveChar + ':\'), Buf, sizeof(Buf), @VolSerNumber, NotUsed, VolFlags, nil, 0));Result := VolSerNumber;end;please help for errorthis code work well in delphi 7 but after upgrade delphi 8 error in GetVolumeInformation ((PChar(DriveChar + ':\'), Buf, sizeof(Buf), @VolSerNumber, NotUsed, VolFlags, nil, 0));[Error] WinForm.pas(89): Invalid typecast[Error] WinForm.pas(89): There is no overloaded version of 'GetVolumeInformation' that can be called with these arguments Link to comment
Encrypto Posted January 24, 2015 Share Posted January 24, 2015 Check how many parameters GetVolumeInformation takes in delphi 8. If there is no problems with number of parameters I suspect that it takes a wide char instead. So change Buff to array of WChar, and use GetVol(PWChar(DriveChar + ':\'). Try that and see how it goes. Link to comment
kao Posted January 24, 2015 Share Posted January 24, 2015 Delphi 8 is a really, really horrible .NET-only version. Unless you really must use it, I strongly suggest you to switch to Delphi 10 or Delphi 2007. Look how the definition of GetVolumeInformation looks like in D8: function GetVolumeInformation(lpRootPathName: string; lpVolumeNameBuffer: StringBuilder; nVolumeNameSize: DWORD; out lpVolumeSerialNumber: DWORD; out lpMaximumComponentLength, lpFileSystemFlags: DWORD; lpFileSystemNameBuffer: StringBuilder; nFileSystemNameSize: DWORD): BOOL; overload;function GetVolumeInformation(lpRootPathName: string; lpVolumeNameBuffer: StringBuilder; nVolumeNameSize: DWORD; lpVolumeSerialNumber: IntPtr; out lpMaximumComponentLength, lpFileSystemFlags: DWORD; lpFileSystemNameBuffer: StringBuilder; nFileSystemNameSize: DWORD): BOOL; overload;function GetVolumeInformationA(lpRootPathName: string; lpVolumeNameBuffer: StringBuilder; nVolumeNameSize: DWORD; out lpVolumeSerialNumber: DWORD; out lpMaximumComponentLength, lpFileSystemFlags: DWORD; lpFileSystemNameBuffer: StringBuilder; nFileSystemNameSize: DWORD): BOOL;function GetVolumeInformationW(lpRootPathName: string; lpVolumeNameBuffer: StringBuilder; nVolumeNameSize: DWORD; out lpVolumeSerialNumber: DWORD; out lpMaximumComponentLength, lpFileSystemFlags: DWORD; lpFileSystemNameBuffer: StringBuilder; nFileSystemNameSize: DWORD): BOOL;lpVolumeNameBuffer is not PChar anymore, you must use StringBuilder instead. 1 Link to comment
Nucleus Posted January 24, 2015 Share Posted January 24, 2015 @mdj Tell me about your avatar, is it from some game? Link to comment
mAStEr pAIn Posted January 25, 2015 Share Posted January 25, 2015 The avatar is from the game "Warcraft III - Frozen Throne"... Look here -> Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now