tags:

views:

2447

answers:

1

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!!!

+6  A: 
[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
pinvoke.net FTW!
Quibblesome
Excellent answer!
DrJokepu