C#Pinvoke SetFilePointer没有设置所需的指针值

时间:2016-04-19 05:43:36

标签: c# pinvoke

我正在使用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

对此有什么想法吗?

0 个答案:

没有答案