Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling winapi::um::fileapi::CreateFileW() #1035

Open
someordinaryidiot opened this issue Nov 27, 2022 · 0 comments
Open

Error when calling winapi::um::fileapi::CreateFileW() #1035

someordinaryidiot opened this issue Nov 27, 2022 · 0 comments

Comments

@someordinaryidiot
Copy link

someordinaryidiot commented Nov 27, 2022

I'm trying to make a backup program for my MBR.
To accomplish this task, I use CreateFileW, but when I try to use this function with the parameters in the documentation (https://docs.rs/winapi/latest/winapi/um/fileapi/fn.CreateFileW.html), I get the following error:
2022-11-27_12-04

My code is: `#[cfg(windows)]
extern crate winapi;
use winapi::shared::minwindef::DWORD;
use winapi::um::fileapi::{CreateFileW, OPEN_EXISTING};
use winapi::um::winnt::{FILE_SHARE_READ, GENERIC_ALL, HANDLE, LPCWSTR};

fn main() {
let mut drive: HANDLE = CreateFileW(
"\\.\PhysicalDrive0" as LPCWSTR,
GENERIC_ALL,
FILE_SHARE_READ,
0 as DWORD,
OPEN_EXISTING,
0 as DWORD,
0 as DWORD,
);
}`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant