How to create file with help of P/Invoke to read boot sector and display .MBR?

拥有回忆 提交于 2019-12-11 10:50:06

问题


I've browsed through the CreateFile documentation... still wondering how should I use P/Invoke to call CreateFile and to read the boot sector, to display out the .MBR?

Any reference code for this portion? Thank you in advance!


回答1:


To expand on Baget's answer, you can call CreateFile like this:

hFile = CreateFile("\\\\.\\physicaldrive0", 
    GENERIC_READ | FILE_SHARE_READ,
    0,
    OPEN_EXISTING,
    0,
    0);



回答2:


Maybe this question will help you

Basically you need to access a device using this syntax in the filename "\\.\PHYSICALDRIVE0"



来源:https://stackoverflow.com/questions/412634/how-to-create-file-with-help-of-p-invoke-to-read-boot-sector-and-display-mbr

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!