Click here to Skip to main content
15,889,816 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,
I am using below function for finding my error:
C++
{
  DWORD err = GetLastError();

  LPVOID lpMsgBuf;

  FormatMessage(
    FORMAT_MESSAGE_ALLOCATE_BUFFER |
    FORMAT_MESSAGE_FROM_SYSTEM |
    FORMAT_MESSAGE_IGNORE_INSERTS,
    NULL,
    GetLastError(),
    MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
    (LPTSTR) &lpMsgBuf,
    0,
    NULL
  );
  MessageBox( NULL, (LPCTSTR)lpMsgBuf, f2, MB_OK | MB_ICONINFORMATION );


  // Free the buffer.
  LocalFree( lpMsgBuf );
}

I got below error:
http://fxturn.com/error/error.jpg[^]

What means this error?
Regards,
Posted
Updated 9-Sep-11 12:29pm
v2
Comments
CPallini 9-Sep-11 15:30pm    
If it is for debugging purposes, why don't you get the numerical value and use the Error Lookup tool of Visual Studio?

In the parameters to FormatMessage, you are calling GetLastError again. This will not get you a message about your error value, err. It will most likely get you something odd, since you've already called GetLastError prior to the call to FormatMessage. :)

[EDIT]
FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
err,
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);

You may need to pass in the actual err value that you want a message for. :)
 
Share this answer
 
v2
Hi,
I used one time but I got same error again.
Regards,
 
Share this answer
 
Comments
Philippe Mori 9-Sep-11 18:35pm    
Please, reply under the solution you want to comment. By the way, check the value of err with a debugger and be sure it is not 0.
Hi,
I done same that but same error too.
Regards,
 
Share this answer
 
Do you always get that empty output with an error, or is it a specific error at the same point in your code.

If it is the same error, it would be useful to know what the error code GetLastError returns for you.
 
Share this answer
 
Hi,
Return error:
VB
ERROR_WINHTTP_TIMEOUT

    12002


Regards,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900