I am really confused by these findings. Please if anybody has any
suggestions or comments on these findings it would be greatly appreciated.
Are you sure that you are doing exactly this all the time:
if (!CallAPI())
{
DWORD dwError = GetLastError();
DoStuffWith(dwError);
}
If you are doing anything else, however similar, you are doing it
wrong. GetLastError is only reliable for a given API after the call to
this API failed (only in rare circumstances it may be valid after a
success, and this is normally noted in MSDN and most likely not your
case).
Goran.
Did API fail? If not, GetLastError ain't good.
if(CallAPI())
{
Do what needs to be done
}
else
{
DWORD dw = GetLastError();
printf(" CallAPI failed, the error code is %X", dw);
if(CallAPI())
{
Do what needs to be done
}
else
{
DWORD dw = GetLastError();
printf(" CallAPI failed, the error code is %X", dw);
> This how I get the error code
>
> if(CallAPI())
> {
> Do what needs to be done
> }
> else
> {
> DWORD dw = GetLastError();
> printf(" CallAPI failed, the error code is %X", dw);
> }
Is CallAPI a Win32 function or your function?
Can you really reproduce your problem in a minimal
sample? Just main or WinMain with your fsiling API-Call and
GetLastError returning an incorrect error.
--
SvenC
The key is what happens within CallAPI() especially after it determines
that there is a failure. It is easy enough to do something in the
internal error handling which would in turn result in the 0xB7 error
code. Something as simple as opening a log file to write status info
would do it.
So again, what is CallAPI()?
Steve
_tprintf(_T(" CallAPI failed, the error code is %d (0x%08x)"), dw, dw);
Note that you are using the placeholder CallAPI to represent an API that has a BOOL return
value. It would be a lot easier to tell what is going on if you showed us the actual API
you called, with the actual parameters you used, instead of just showing us an abstract
example.
joe
Joseph M. Newcomer [MVP]
email: newc...@flounder.com
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm