Getting Error message instead Error Code number

void GetErrorMessage(const DWORD e, CString &Message) {
LPTSTR lpMsgBuf=NULL;
DWORD Size, fme;
Size = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
NULL, e, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
(LPTSTR)&lpMsgBuf, 0, NULL);
fme = GetLastError();
if (lpMsgBuf) {
Message = lpMsgBuf;
LocalFree(lpMsgBuf);
if (Size)
return;
}
if (fme)
Message.Format(_T(”FormatMessage error code %u”), fme);
else
Message.Format(_T(”unknown error code %u”), e);
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: