Home > Archive > Smartphone Developer Forum > January 2006 > Need help with FormatMessage
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Need help with FormatMessage
|
|
| Norman Diamond 2006-01-23, 4:00 am |
| Running in the Smartphone emulator under eVC++4 SP4.
DWORD ErrNum;
LPTSTR pErrMsg;
ErrNum = GetLastError();
FormatMessage((FORMAT_MESSAGE_ALLOCATE_B
UFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_ARGUMENT_ARRAY |
FORMAT_MESSAGE_IGNORE_INSERTS),
NULL, ErrNum, 0, (LPTSTR) &pErrMsg, 0, NULL);
MessageBox(NULL, pErrMsg, _T("Bug 1"), 0);
LocalFree((HLOCAL) pErrMsg);
pErrMsg = NULL;
ErrNum can be viewed in the debugger and its value is 1814. The garbage
displayed in the message box is mostly square boxes. The garbage even
sometimes changes from run to run, though ErrNum is always 1814 as mentioned
in my other posting.
I understand that OEMs often exclude error message texts from their ROMs,
but this is the emulator. Anyone know how to persuade FormatMessage to
work?
| |
| Alex Feinman [MVP] 2006-01-24, 3:59 am |
| What does FormatMessage return? If zero, what is the value returned by
GetLastError() after the call to FormatMessage?
"Norman Diamond" <ndiamond@community.nospam> wrote in message
news:uIKfTDAIGHA.1676@TK2MSFTNGP09.phx.gbl...
> Running in the Smartphone emulator under eVC++4 SP4.
>
> DWORD ErrNum;
> LPTSTR pErrMsg;
> ErrNum = GetLastError();
> FormatMessage((FORMAT_MESSAGE_ALLOCATE_B
UFFER |
> FORMAT_MESSAGE_FROM_SYSTEM |
> FORMAT_MESSAGE_ARGUMENT_ARRAY |
> FORMAT_MESSAGE_IGNORE_INSERTS),
> NULL, ErrNum, 0, (LPTSTR) &pErrMsg, 0, NULL);
> MessageBox(NULL, pErrMsg, _T("Bug 1"), 0);
> LocalFree((HLOCAL) pErrMsg);
> pErrMsg = NULL;
>
> ErrNum can be viewed in the debugger and its value is 1814. The garbage
> displayed in the message box is mostly square boxes. The garbage even
> sometimes changes from run to run, though ErrNum is always 1814 as
> mentioned
> in my other posting.
>
> I understand that OEMs often exclude error message texts from their ROMs,
> but this is the emulator. Anyone know how to persuade FormatMessage to
> work?
>
| |
| Norman Diamond 2006-01-24, 3:59 am |
| Bingo. FormatMessage returned 0 and FormatMessage's own error code is 317.
Using the error lookup utility from Visual Studio 6, translating and then
interpreting, error code 317 roughly means that Microsoft didn't put a
message text for the preceding error code 1814 in the Windows CE
configuration in the Smartphone 2003 emulator. OK, so FormatMessage also
didn't put a valid pointer into the location pointed to by the lpBuffer
argument, and/or didn't null terminate the null string that it might or
might not have written.
Now why would anyone expect the emulator to run in an environment with
sufficient memory for error message texts. Silly me.
But you are right, I was negligent in not error checking my error checking
code. Thank you.
Now if anyone knows how to get FindResource to work, my new error checking
code error checking code won't even need to get executed any more.
"Alex Feinman [MVP]" <public_news@alexfeinman.com> wrote in message
news:uXU4eULIGHA.1132@TK2MSFTNGP10.phx.gbl...
> What does FormatMessage return? If zero, what is the value returned by
> GetLastError() after the call to FormatMessage?
>
> "Norman Diamond" <ndiamond@community.nospam> wrote in message
> news:uIKfTDAIGHA.1676@TK2MSFTNGP09.phx.gbl...
>
|
|
|
|
|