如题
比如我现在
int error=GetLastError();得到的error=10093
我怎么查看10093是什么错?在哪找?还有一个问题是
try{} catch(){}
在catch里怎么把出错的信息打印出来?

解决方案 »

  1.   

    使用FormatMessage函数,函数具体用法可以查看MSDN
      

  2.   

    vc Tools 里面有个error lookup程序,可以查看错误代码的含义
      

  3.   

    应用程序没有调用 WSAStartup,或者 WSAStartup 失败。
      

  4.   

    调试时,在Watch框里面输入 @err,hr
      

  5.   

    @eax,hr 这样可以看自己函数的返回值,一般的都存在EAX寄存器中,在output中看了,还有winscok中系列有专门的WSAGetLastError错误信息,
     用FormatMessage可以直接在程序中转换为显示中文的错误
    也可以用vs中的error lookup
      

  6.   

    楼上的最好,有error lookup,用的着自己写吗
      

  7.   

    废话,如果错误要给用户看,你给用户时要带上error lookup
    吗,不要抄袭,没道德
      

  8.   

    Example Code 
    The FormatMessage function can be used to obtain error message strings for the system error codes returned by GetLastError, as shown in the following sample code.LPVOID lpMsgBuf;
    if (!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 ))
    {
       // Handle the error.
       return;
    }// Process any inserts in lpMsgBuf.
    // ...// Display the string.
    MessageBox( NULL, (LPCTSTR)lpMsgBuf, "Error", MB_OK | MB_ICONINFORMATION );// Free the buffer.
    LocalFree( lpMsgBuf );
    For an additional example, see Looking Up Text for Error Code Numbers.
      

  9.   

    我用的VC简装版,好像没有什么error lookup
      

  10.   

    多谢各位  我用MSDN上的实例代码把错误显示出来了但还是不会用error lookup   那个在哪里呢?
      

  11.   

    VC有个小工具的。输入错误码,就可以看到原因了。
    Tools->error lookup