9

After getting so much information about retrieving .MBR from a storage device, conclusion is to use P/Invoke to call CreateFile.

But how this can be done in C#? Please illustrate! Your help will be greatly appreciated!!!

Community
  • 1
  • 1
yen
  • 117
  • 1
  • 2
  • 3

1 Answers1

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

David Brown
  • 35,411
  • 11
  • 83
  • 132