Skip to content

Commit f8a73cb

Browse files
committed
Add GetModuleFileNameExW to the module-filename-generic.rs example.
1 parent 56c9c88 commit f8a73cb

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

grob/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ features = [
3535
"Win32_NetworkManagement_Ndis",
3636
"Win32_Storage_FileSystem",
3737
"Win32_System_LibraryLoader",
38+
"Win32_System_ProcessStatus",
3839
"Win32_System_SystemInformation",
40+
"Win32_System_Threading",
3941
"Win32_System_WindowsProgramming",
4042
]
4143

grob/examples/module-filename-generic.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@
1414

1515
use windows::Win32::Foundation::HMODULE;
1616
use windows::Win32::System::LibraryLoader::GetModuleFileNameW;
17+
use windows::Win32::System::ProcessStatus::GetModuleFileNameExW;
18+
use windows::Win32::System::Threading::GetCurrentProcess;
1719

1820
use grob::{winapi_path_buf, RvIsSize};
1921

@@ -22,5 +24,11 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
2224
RvIsSize::new(unsafe { GetModuleFileNameW(HMODULE(0), argument.as_mut_slice()) })
2325
})?;
2426
println!("GetModuleFileNameW returned {}", path.display());
27+
28+
let path = winapi_path_buf(|argument| {
29+
RvIsSize::new(unsafe { GetModuleFileNameExW(GetCurrentProcess(), HMODULE(0), argument.as_mut_slice()) })
30+
})?;
31+
println!("GetModuleFileNameExW returned {}", path.display());
32+
2533
Ok(())
2634
}

0 commit comments

Comments
 (0)