我正在使用pinvoke的createfile方法来创建驱动器的句柄,但是当我尝试使用SetFilePointer时,它使用SafeFileHandle将它设置为垃圾位置。
[DllImport("Kernel32.dll", SetLastError = true, CharSet = CharSet.Auto)]
static extern ulong SetFilePointer([In] SafeFileHandle hFile, [In] long lDistanceToMove, ref IntPtr lpDistanceToMoveHigh, [In] EMoveMethod dwMoveMethod);
[DllImport("kernel32.dll", SetLastError = true, CharSet = CharSet.Unicode)]
static extern SafeFileHandle CreateFile(string lpFileName, uint dwDesiredAccess, uint dwShareMode, IntPtr lpSecurityAttributes, uint dwCreationDisposition, uint dwFlagsAndAttributes, IntPtr hTemplateFile);
dwCurrentFilePosition = SetFilePointer(diskHandle, 0, ref hWrite, EMoveMethod.Begin);
即使在上面的代码中将其设置为零,它也会将其设置为某个位置348966092800
对此有什么想法吗?