#include <windows.h> #include <stdio.h> #include <tchar.h> #include <iostream> using namespace std; int main(int argc,char **argv[]){ DWORD dwError = 2; HLOCAL hlocal = NULL;
BOOL fOk = FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER, NULL, dwError, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (PTSTR) &hlocal, 0, NULL);
if (!fOk) { // Is it a network-related error?
HMODULE hDll = LoadLibraryEx(TEXT("netmsg.dll"), NULL, DONT_RESOLVE_DLL_REFERENCES);
if (hDll != NULL) { FormatMessage( FORMAT_MESSAGE_FROM_HMODULE | FORMAT_MESSAGE_FROM_SYSTEM, hDll, dwError, MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), (PTSTR) &hlocal, 0, NULL); FreeLibrary(hDll); } } if (hlocal != NULL) { wprintf(_T("error mean:%s\n"),LocalLock(hlocal)); LocalFree(hlocal); } else { printf("Error number not found.\n"); } return 0; }
|