FYI:
I don't know if it maters but the windows DLL's I've used want the strings as widestring as shown in this snpit
function TChkDsk.CheckDriveExists (const WDrive: WideString;
CheckInUse: boolean ; var WFormat: WideString): boolean ;
var
FileSysName : Array[0..MAX_PATH] of WChar;
VolumeName : Array[0..MAX_PATH] of WChar;
maxcomlen, flags: longword;
handle: THandle ;
voldev: WideString ;
begin
if (Length (WDrive) < 2) or (WDrive [2] <> ':') then begin
raise FmtChkException.Create('Invalid Drive Specification: ' + WDrive);
exit ;
end ;
// see if volume exists, get file system (FAT32, NTFS)
if NOT GetVolumeInformationW (PWChar (WDrive), VolumeName, SizeOf(VolumeName) div 2,
Nil, maxcomlen, flags, FileSysName, SizeOf(FileSysName) div 2) then
begin
raise FmtChkException.Create('Drive Not Found: ' + WDrive);
exit ;
end ;
WFormat := FileSysName ;
doInfoEvent (WDrive + ' Volume Label: ' + VolumeName + ', File System: ' + FileSysName) ;
// try and get exclusive access to volume
if CheckInUse then
begin
voldev := '\\.\' + WDrive [1] + ':' ;
handle := CreateFileW (PWChar (voldev), Generic_Write, 0, nil, Open_Existing, 0, 0) ;
if handle = INVALID_HANDLE_VALUE then
begin
raise FmtChkException.Create('Drive In Use: ' + WDrive);
exit ;
end ;
CloseHandle (handle) ;
end ;
result := true ;
End;