mirror of
https://github.com/gnustep/libs-gui.git
synced 2025-04-22 20:50:44 +00:00
Fix crash - don't print DWORD error code directly, but decode it first.
This commit is contained in:
parent
28cb389130
commit
39686d5dd6
1 changed files with 10 additions and 1 deletions
|
@ -65,7 +65,16 @@ NSMutableDictionary *EnumeratePrinters(DWORD flags)
|
|||
if (!EnumPrinters(flags, NULL,
|
||||
2, (LPBYTE) prninfo, needed, &needed, &returned))
|
||||
{
|
||||
NSLog(@"Error: %s\n", GetLastError());
|
||||
DWORD errorCode = GetLastError();
|
||||
char *errorText = NULL;
|
||||
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM||FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_IGNORE_INSERTS,
|
||||
NULL,
|
||||
errorCode,
|
||||
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
||||
(LPTSTR)&errorText,
|
||||
0, NULL);
|
||||
NSLog(@"Error: %lu: %s\n", errorCode, errorText);
|
||||
LocalFree(errorText);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue