Usage zero as language id for FormatMessageW()
This commit is contained in:
parent
d06ca0ffaf
commit
4504cc513f
1 changed files with 2 additions and 6 deletions
|
@ -25,10 +25,6 @@ pub fn errno() -> i32 {
|
|||
|
||||
/// Gets a detailed string description for the given error number.
|
||||
pub fn error_string(mut errnum: i32) -> String {
|
||||
// This value is calculated from the macro
|
||||
// MAKELANGID(LANG_SYSTEM_DEFAULT, SUBLANG_SYS_DEFAULT)
|
||||
let langId = 0x0800 as c::DWORD;
|
||||
|
||||
let mut buf = [0 as c::WCHAR; 2048];
|
||||
|
||||
unsafe {
|
||||
|
@ -56,13 +52,13 @@ pub fn error_string(mut errnum: i32) -> String {
|
|||
flags | c::FORMAT_MESSAGE_FROM_SYSTEM | c::FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
module,
|
||||
errnum as c::DWORD,
|
||||
langId,
|
||||
0,
|
||||
buf.as_mut_ptr(),
|
||||
buf.len() as c::DWORD,
|
||||
ptr::null(),
|
||||
) as usize;
|
||||
if res == 0 {
|
||||
// Sometimes FormatMessageW can fail e.g., system doesn't like langId,
|
||||
// Sometimes FormatMessageW can fail e.g., system doesn't like 0 as langId,
|
||||
let fm_err = errno();
|
||||
return format!("OS Error {errnum} (FormatMessageW() returned error {fm_err})");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue