regedit: Combine error() and error_code_messagebox().

Signed-off-by: Hugh McMaster <hugh.mcmaster@outlook.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hugh McMaster 2017-02-01 12:56:51 +00:00 committed by Alexandre Julliard
parent e0ab47ce87
commit 6a8aea20ac
3 changed files with 11 additions and 16 deletions

View File

@ -76,20 +76,15 @@ static INT __cdecl messagebox(HWND hwnd, INT buttons, INT titleId, INT resId, ..
return result; return result;
} }
void __cdecl error(HWND hwnd, INT resId, ...) void __cdecl error_code_messagebox(HWND hwnd, unsigned int msg_id, ...)
{ {
__ms_va_list ap; __ms_va_list ap;
__ms_va_start(ap, resId); __ms_va_start(ap, msg_id);
vmessagebox(hwnd, MB_OK | MB_ICONERROR, IDS_ERROR, resId, ap); vmessagebox(hwnd, MB_OK|MB_ICONERROR, IDS_ERROR, msg_id, ap);
__ms_va_end(ap); __ms_va_end(ap);
} }
static void error_code_messagebox(HWND hwnd, unsigned int msg_id)
{
vmessagebox(hwnd, MB_OK|MB_ICONERROR, IDS_ERROR, msg_id, NULL);
}
static BOOL change_dword_base(HWND hwndDlg, BOOL toHex) static BOOL change_dword_base(HWND hwndDlg, BOOL toHex)
{ {
static const WCHAR percent_u[] = {'%','u',0}; static const WCHAR percent_u[] = {'%','u',0};
@ -214,17 +209,17 @@ static LPWSTR read_value(HWND hwnd, HKEY hKey, LPCWSTR valueName, DWORD *lpType,
*buffer = '\0'; *buffer = '\0';
return buffer; return buffer;
} }
error(hwnd, IDS_BAD_VALUE, valueName); error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
goto done; goto done;
} }
if ( *lpType == REG_DWORD ) valueDataLen = sizeof(DWORD); if ( *lpType == REG_DWORD ) valueDataLen = sizeof(DWORD);
if (!(buffer = HeapAlloc(GetProcessHeap(), 0, valueDataLen+sizeof(WCHAR)))) { if (!(buffer = HeapAlloc(GetProcessHeap(), 0, valueDataLen+sizeof(WCHAR)))) {
error(hwnd, IDS_TOO_BIG_VALUE, valueDataLen); error_code_messagebox(hwnd, IDS_TOO_BIG_VALUE, valueDataLen);
goto done; goto done;
} }
lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen); lRet = RegQueryValueExW(hKey, valueName, 0, 0, (LPBYTE)buffer, &valueDataLen);
if (lRet != ERROR_SUCCESS) { if (lRet != ERROR_SUCCESS) {
error(hwnd, IDS_BAD_VALUE, valueName); error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
goto done; goto done;
} }
if((valueDataLen % sizeof(WCHAR)) == 0) if((valueDataLen % sizeof(WCHAR)) == 0)
@ -375,7 +370,7 @@ BOOL ModifyValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName)
else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED); else error_code_messagebox(hwnd, IDS_SET_VALUE_FAILED);
} }
} else { } else {
error(hwnd, IDS_UNSUPPORTED_TYPE, type); error_code_messagebox(hwnd, IDS_UNSUPPORTED_TYPE, type);
} }
done: done:
@ -402,7 +397,7 @@ BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath)
lRet = SHDeleteKeyW(hKeyRoot, keyPath); lRet = SHDeleteKeyW(hKeyRoot, keyPath);
if (lRet != ERROR_SUCCESS) { if (lRet != ERROR_SUCCESS) {
error(hwnd, IDS_BAD_KEY, keyPath); error_code_messagebox(hwnd, IDS_BAD_KEY, keyPath);
goto done; goto done;
} }
result = TRUE; result = TRUE;
@ -431,7 +426,7 @@ BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, B
lRet = RegDeleteValueW(hKey, valueName ? valueName : &empty); lRet = RegDeleteValueW(hKey, valueName ? valueName : &empty);
if (lRet != ERROR_SUCCESS && valueName) { if (lRet != ERROR_SUCCESS && valueName) {
error(hwnd, IDS_BAD_VALUE, valueName); error_code_messagebox(hwnd, IDS_BAD_VALUE, valueName);
} }
if (lRet != ERROR_SUCCESS) goto done; if (lRet != ERROR_SUCCESS) goto done;
result = TRUE; result = TRUE;

View File

@ -773,7 +773,7 @@ static BOOL _CmdWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
SetFocus(g_pChildWnd->hTreeWnd); SetFocus(g_pChildWnd->hTreeWnd);
} }
} else { } else {
error(hWnd, IDS_NOTFOUND, searchString); error_code_messagebox(hWnd, IDS_NOTFOUND, searchString);
} }
} }
break; break;

View File

@ -143,7 +143,7 @@ extern BOOL DeleteKey(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath);
extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, BOOL showMessageBox); extern BOOL DeleteValue(HWND hwnd, HKEY hKeyRoot, LPCWSTR keyPath, LPCWSTR valueName, BOOL showMessageBox);
extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR oldName, LPCWSTR newName); extern BOOL RenameValue(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR oldName, LPCWSTR newName);
extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName); extern BOOL RenameKey(HWND hwnd, HKEY hRootKey, LPCWSTR keyPath, LPCWSTR newName);
extern void __cdecl error(HWND hwnd, INT resId, ...); extern void __cdecl error_code_messagebox(HWND hwnd, unsigned int msg_id, ...);
/* hexedit.c */ /* hexedit.c */
extern void HexEdit_Register(void); extern void HexEdit_Register(void);