I have a simple class derivated from THandleStream which I use to edit a raw volume. I call Windows createfile() function to open a drive but the function never returns a valid handle, rather an exotic error code( 348 at the debugtime and 304 at the runtime, but the error is not raised, this is just that the handle value looks wierd). this is what I'm doing:
Constructor TDiskStream.Create(Const aDrive: String);
Var
Hdl: Cardinal;
A,B: Int64;
Begin
Hdl := CreateFile( PChar(ADrive),
GENERIC_WRITE,
FILE_SHARE_READ Or FILE_SHARE_WRITE,
0, OPEN_EXISTING, 0, 0);
Inherited Create( Hdl );
GetDiskFreeSpaceEx( PChar( RightStr(ADrive,2) + '\'), A, FSize, @B );
End;
The handle value matchs to the error code described as ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING on msdn, but it seems to be very uncommon. The aDrive parameter is set correctly ( in the format \\.\x: ).
What's wrong here, how can I manage to get my valid file handle ?