获取错误码

 CString FormartLastError()
{
    //if (Error==0)
    //    Error=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
        (TCHAR *) &lpMsgBuf,
        0,
        NULL
        );
    TCHAR *p=(TCHAR*)lpMsgBuf;
    CString str=p;
   
    LocalFree( lpMsgBuf );
    return str;
}

你可能感兴趣的:(null,System,buffer)