[REGEDIT]
[reactos.git] / reactos / base / applications / regedit / error.c
1 #include <regedit.h>
2 void ErrorMessageBox(HWND hWnd, LPCTSTR title, DWORD code)
3 {
4 LPTSTR lpMsgBuf;
5 DWORD status;
6 static const TCHAR fallback[] = TEXT("Error displaying error message.\n");
7 status = FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
8 NULL, code, 0, (LPTSTR)&lpMsgBuf, 0, NULL);
9 if (!status)
10 lpMsgBuf = (LPTSTR)fallback;
11 MessageBox(hWnd, lpMsgBuf, title, MB_OK | MB_ICONERROR);
12 if (lpMsgBuf != fallback)
13 LocalFree(lpMsgBuf);
14 }