Mail Archives: cygwin/2002/07/30/01:44:21
------=_NextPart_000_003D_01C23751.77A361F0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
----- Original Message -----
From: "Paul Derbyshire" <derbyshire AT globalserve DOT net>
To: <cygwin AT cygwin DOT com>
Sent: Friday, July 26, 2002 6:23 PM
Subject: Mysterious gdb behavior.
>
> Error: Error creating process <image path>, (error 193)
>
> Then you look at the documentation. There's no documentation of the
> error codes.
Attached is a small Windows console program that will send to standard
output all Windows error messages associated with a Windows error code. It
can be used as-is by redirecting standard output to a file but the program
is intended to just be a sample. I am not sure what would be the most useful
way for CygWin users to use this. Obviously the best solution is for
FormatMessage, as used by this small sample, to be called for Windows error
codes (usually returned by Windows GetLastError function) so that the error
message can be provided with or instead of the error code. In other words,
if FormatMessage is called with 193 as error code, it will return "%1 is not
a valid Win32 application" where %1 will be the exe file.
Well I just executed a compiled version of the program and the output is not
perfect so perhaps this can only be used as a sample. The important thing is
that it shows how FormatMessage can be used.
------=_NextPart_000_003D_01C23751.77A361F0
Content-Type: application/octet-stream;
name="WinErrors.cpp"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="WinErrors.cpp"
#pragma warning(disable:4786)
#define STRICT 1
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <iostream>
using namespace std;
#pragma hdrstop
// * * * * * * * * * *
LONG lErrorCodeCount=3D0;
bool DisplayError(LONG lErrorCode) {
LPTSTR lpMsgBuf=3DNULL;
int ReturnSize;
ReturnSize =3D FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |=20
FORMAT_MESSAGE_FROM_SYSTEM |=20
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
lErrorCode,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR)&lpMsgBuf,
0,
NULL);
if (!lpMsgBuf || !ReturnSize)
return false;
++lErrorCodeCount;
cout << lErrorCode << ' ' << lpMsgBuf;
LocalFree(lpMsgBuf);
return true;
}
// * * * * * * * * * *
int main(int argc, char *argv[], char *envp[]) {
LONG lLastErrorCode, lErrorCode;
// First find the last error code
for (lLastErrorCode=3D0x4FFF; !DisplayError(lLastErrorCode); =
--lLastErrorCode);
cout << lLastErrorCode << " last error code\n";
for (lErrorCode=3D0; lErrorCode<lLastErrorCode; ++lErrorCode)
DisplayError(lErrorCode);
cout << lErrorCodeCount << " total error messages\n";
return 0;
}
------=_NextPart_000_003D_01C23751.77A361F0
Content-Type: text/plain; charset=us-ascii
--
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
Bug reporting: http://cygwin.com/bugs.html
Documentation: http://cygwin.com/docs.html
FAQ: http://cygwin.com/faq/
------=_NextPart_000_003D_01C23751.77A361F0--
- Raw text -