Hey mate, what library am I importing because it fails to build.
I get the following errors:
error[E0433]: failed to resolve: could not find `Windows` in `bindings`
--> src\main.rs:6:15
|
6 | use bindings::Windows::Win32::System::SystemServices::PWSTR;
| ^^^^^^^ could not find `Windows` in `bindings`
error[E0433]: failed to resolve: could not find `Windows` in `bindings`
--> src\main.rs:7:15
|
7 | use bindings::Windows::Win32::UI::Shell::ShellExecuteW;
| ^^^^^^^ could not find `Windows` in `bindings`
error[E0433]: failed to resolve: could not find `Windows` in `bindings`
--> src\main.rs:8:15
|
8 | use bindings::Windows::Win32::UI::WindowsAndMessaging::HWND;
| ^^^^^^^ could not find `Windows` in `bindings`
error[E0433]: failed to resolve: use of undeclared crate or module `windows`
--> src\main.rs:3:5
|
3 | windows::include_bindings!();
| ^^^^^^^ use of undeclared crate or module `windows`
error[E0433]: failed to resolve: use of undeclared crate or module `windows`
--> src\main.rs:12:5
|
12 | windows::initialize_sta().unwrap();
| ^^^^^^^ use of undeclared crate or module `windows`
error[E0433]: failed to resolve: use of undeclared type `HWND`
--> src\main.rs:13:36
|
13 | let r = unsafe { ShellExecuteW(HWND::NULL, "runas", "C:\\Windows\\System32\\cmd.exe", PWSTR::NULL, PWSTR::NULL, 1) };
| ^^^^ use of undeclared type `HWND`
error[E0433]: failed to resolve: use of undeclared type `PWSTR`
--> src\main.rs:13:91
|
13 | let r = unsafe { ShellExecuteW(HWND::NULL, "runas", "C:\\Windows\\System32\\cmd.exe", PWSTR::NULL, PWSTR::NULL, 1) };
| ^^^^^ use of undeclared type `PWSTR`
error[E0433]: failed to resolve: use of undeclared type `PWSTR`
--> src\main.rs:13:104
|
13 | let r = unsafe { ShellExecuteW(HWND::NULL, "runas", "C:\\Windows\\System32\\cmd.exe", PWSTR::NULL, PWSTR::NULL, 1) };
| ^^^^^ use of undeclared type `PWSTR`
error[E0425]: cannot find function, tuple struct or tuple variant `ShellExecuteW` in this scope
--> src\main.rs:13:22
|
13 | let r = unsafe { ShellExecuteW(HWND::NULL, "runas", "C:\\Windows\\System32\\cmd.exe", PWSTR::NULL, PWSTR::NULL, 1) };
| ^^^^^^^^^^^^^ not found in this scope
error: aborting due to 9 previous errors
Some errors have detailed explanations: E0425, E0433.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `learning`
To learn more, run the command again with --verbose.
after using your code:
mod bindings {
windows::include_bindings!();
}
use bindings::Windows::Win32::System::SystemServices::PWSTR;
use bindings::Windows::Win32::UI::Shell::ShellExecuteW;
use bindings::Windows::Win32::UI::WindowsAndMessaging::HWND;
fn main() {
windows::initialize_sta().unwrap();
let r = unsafe { ShellExecuteW(HWND::NULL, "runas", "C:\\Windows\\System32\\cmd.exe", PWSTR::NULL, PWSTR::NULL, 1) };
if r.0 < 32 {
println!("error: {:?}", r);
}
}