2012-10-01 23:16:43 +00:00
|
|
|
/*
|
|
|
|
* Regedit errors, warnings, informations displaying
|
|
|
|
*
|
|
|
|
* Copyright (C) 2010 Adam Kachwalla <geekdundee@gmail.com>
|
|
|
|
* Copyright (C) 2012 Hermès Bélusca - Maïto <hermes.belusca@sfr.fr>
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2010-11-04 12:05:35 +00:00
|
|
|
#include <regedit.h>
|
2012-10-01 23:16:43 +00:00
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
int ErrorMessageBox(HWND hWnd, LPCWSTR lpTitle, DWORD dwErrorCode, ...)
|
2010-11-04 12:05:35 +00:00
|
|
|
{
|
2012-10-01 23:16:43 +00:00
|
|
|
int iRet = 0;
|
2012-10-03 22:42:34 +00:00
|
|
|
LPWSTR lpMsgBuf = NULL;
|
2012-10-01 23:16:43 +00:00
|
|
|
DWORD Status = 0;
|
|
|
|
|
|
|
|
va_list args = NULL;
|
|
|
|
va_start(args, dwErrorCode);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM,
|
|
|
|
NULL,
|
|
|
|
dwErrorCode,
|
|
|
|
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
|
|
|
|
(LPWSTR)&lpMsgBuf,
|
|
|
|
0,
|
|
|
|
&args);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message.\n"), lpTitle, MB_OK | MB_ICONERROR);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
/* Return the MessageBoxW information */
|
2012-10-01 23:16:43 +00:00
|
|
|
return iRet;
|
|
|
|
}
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
int InfoMessageBox(HWND hWnd, UINT uType, LPCWSTR lpTitle, LPCWSTR lpMessage, ...)
|
2012-10-01 23:16:43 +00:00
|
|
|
{
|
|
|
|
int iRet = 0;
|
2012-10-03 22:42:34 +00:00
|
|
|
LPWSTR lpMsgBuf = NULL;
|
2012-10-01 23:16:43 +00:00
|
|
|
DWORD Status = 0;
|
|
|
|
|
|
|
|
va_list args = NULL;
|
|
|
|
va_start(args, lpMessage);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
Status = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_STRING,
|
|
|
|
lpMessage,
|
|
|
|
0,
|
|
|
|
0,
|
|
|
|
(LPWSTR)&lpMsgBuf,
|
|
|
|
0,
|
|
|
|
&args);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
va_end(args);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
iRet = MessageBoxW(hWnd, (Status && lpMsgBuf ? lpMsgBuf : L"Error displaying error message.\n"), lpTitle, uType);
|
2012-10-01 23:16:43 +00:00
|
|
|
|
|
|
|
if (lpMsgBuf) LocalFree(lpMsgBuf);
|
|
|
|
|
2012-10-03 22:42:34 +00:00
|
|
|
/* Return the MessageBoxW information */
|
2012-10-01 23:16:43 +00:00
|
|
|
return iRet;
|
2010-11-04 12:05:35 +00:00
|
|
|
}
|