Skip to content

Commit a87a136

Browse files
committed
Code
1 parent 5e8f49d commit a87a136

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Process/ShellExecute.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
extern crate winapi;
2+
3+
// MSDN For ShellExecute : https://learn.microsoft.com/en-us/windows/win32/api/shellapi/nf-shellapi-shellexecutea
4+
use winapi::um::{winuser::SW_SHOWNORMAL,
5+
shellapi::ShellExecuteA};
6+
use std::ptr;
7+
use std::ffi::CString;
8+
use winapi::shared::ntdef::NULL;
9+
10+
fn main() {
11+
let command = CString::new("calc.exe").unwrap();
12+
let verb = CString::new("runas").unwrap();
13+
14+
// For Folder ..
15+
// let parameters = CString::new("").unwrap();
16+
// let directory = CString::new("").unwrap();
17+
let dirc = NULL as _;
18+
19+
unsafe {
20+
ShellExecuteA(
21+
ptr::null_mut(),
22+
verb.as_ptr(),
23+
command.as_ptr(),
24+
dirc,
25+
dirc,
26+
SW_SHOWNORMAL,
27+
);
28+
}
29+
}

0 commit comments

Comments
 (0)