I have a simple class created from THandleStream that I use to edit a raw volume. I call the createfile () function of Windows to open the disk, but the function never returns a valid descriptor, but rather an exotic error code (348 in debug mode and 304 at runtime, but the error does not occur, it's just that the descriptor value looks weird ) this is what i am 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 descriptor value corresponds to the error code ERROR_INCOMPATIBLE_WITH_GLOBAL_SHORT_NAME_REGISTRY_SETTING on msdn, but this seems very unusual. The aDrive parameter is set correctly (in the format \\. \ X:) .
What's wrong here, how do I manage to get my actual file descriptor?