- if (GetLastError() != 0)
- {
- LPVOID lpMsgBuf;
- FormatMessage(
- FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- 0,
- GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf,
- 0,
- 0
- );
- strcat( text, "GetLastError: " );
- /*
- Gtk will only crunch 0<=char<=127
- this is a bit hackish, but I didn't find useful functions in win32 API for this
- http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516
- */
- TCHAR *scan, *next = (TCHAR*)lpMsgBuf;
- do
- {
- scan = next;
- text[strlen(text)+1] = '\0';
- if ((scan[0] >= 0) && (scan[0] <= 127))
- text[strlen(text)] = char(scan[0]);
- else
- text[strlen(text)] = '?';
- next = CharNext(scan);
- } while (next != scan);
- strcat( text, "\n");
- LocalFree( lpMsgBuf );
- }
+ if ( GetLastError() != 0 ) {
+ LPVOID lpMsgBuf;
+ FormatMessage(
+ FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ 0,
+ GetLastError(),
+ MAKELANGID( LANG_NEUTRAL, SUBLANG_DEFAULT ), // Default language
+ (LPTSTR) &lpMsgBuf,
+ 0,
+ 0
+ );
+ strcat( text, "GetLastError: " );
+ /*
+ Gtk will only crunch 0<=char<=127
+ this is a bit hackish, but I didn't find useful functions in win32 API for this
+ http://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=516
+ */
+ TCHAR *scan, *next = (TCHAR*)lpMsgBuf;
+ do
+ {
+ scan = next;
+ text[strlen( text ) + 1] = '\0';
+ if ( ( scan[0] >= 0 ) && ( scan[0] <= 127 ) ) {
+ text[strlen( text )] = char(scan[0]);
+ }
+ else{
+ text[strlen( text )] = '?';
+ }
+ next = CharNext( scan );
+ } while ( next != scan );
+ strcat( text, "\n" );
+ LocalFree( lpMsgBuf );
+ }