9

在得到了这么多关于从存储设备中检索 .MBR的信息之后,结论是使用 P/Invoke 来调用CreateFile.

但是如何在 C# 中做到这一点?请举例说明!对你的帮助表示感谢!!!

4

1 回答 1

20
[DllImport("kernel32.dll", CharSet = CharSet.Auto, 
    CallingConvention = CallingConvention.StdCall, 
    SetLastError = true)]
public static extern SafeFileHandle CreateFile(
    string lpFileName,
    uint dwDesiredAccess,
    uint dwShareMode,
    IntPtr SecurityAttributes,
    uint dwCreationDisposition,
    uint dwFlagsAndAttributes,
    IntPtr hTemplateFile
);

http://pinvoke.net/default.aspx/kernel32/CreateFile.html

于 2009-01-05T13:14:09.447 回答