[Box Backup-commit] COMMIT r3568 - box/trunk/lib/win32
subversion at boxbackup.org
subversion at boxbackup.org
Sat May 16 10:17:29 BST 2015
Author: chris
Date: 2015-05-16 09:17:29 +0000 (Sat, 16 May 2015)
New Revision: 3568
Modified:
box/trunk/lib/win32/emu.cpp
Log:
Fix error reporting from Reg* functions.
Unlike the rest of the Win32 API, these functions return their error code,
and it's not accessible using GetLastError(). Thanks to Enrique Perez-Terron
for reporting this issue.
Modified: box/trunk/lib/win32/emu.cpp
===================================================================
--- box/trunk/lib/win32/emu.cpp 2015-05-16 09:17:25 UTC (rev 3567)
+++ box/trunk/lib/win32/emu.cpp 2015-05-16 09:17:29 UTC (rev 3568)
@@ -1337,11 +1337,11 @@
HKEY hk;
DWORD dwDisp;
- if (RegCreateKeyEx(HKEY_LOCAL_MACHINE, regkey.c_str(),
- 0, NULL, REG_OPTION_NON_VOLATILE,
- KEY_WRITE, NULL, &hk, &dwDisp))
+ winerrno = RegCreateKeyEx(HKEY_LOCAL_MACHINE, regkey.c_str(),
+ 0, NULL, REG_OPTION_NON_VOLATILE,
+ KEY_WRITE, NULL, &hk, &dwDisp);
+ if (winerrno != ERROR_SUCCESS)
{
- winerrno = GetLastError();
::syslog(LOG_ERR, "Failed to create the registry key: %s",
GetErrorMessage(winerrno).c_str());
return FALSE;
@@ -1349,14 +1349,14 @@
// Set the name of the message file.
- if (RegSetValueExW(hk, // subkey handle
- L"EventMessageFile", // value name
- 0, // must be zero
- REG_EXPAND_SZ, // value type
- (LPBYTE)cmd, // pointer to value data
- len*sizeof(WCHAR))) // data size
+ winerrno = RegSetValueExW(hk, // subkey handle
+ L"EventMessageFile", // value name
+ 0, // must be zero
+ REG_EXPAND_SZ, // value type
+ (LPBYTE)cmd, // pointer to value data
+ len*sizeof(WCHAR)); // data size
+ if (winerrno != ERROR_SUCCESS)
{
- winerrno = GetLastError();
::syslog(LOG_ERR, "Failed to set the event message file: %s",
GetErrorMessage(winerrno).c_str());
RegCloseKey(hk);
@@ -1368,14 +1368,14 @@
DWORD dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
EVENTLOG_INFORMATION_TYPE;
- if (RegSetValueEx(hk, // subkey handle
- "TypesSupported", // value name
- 0, // must be zero
- REG_DWORD, // value type
- (LPBYTE) &dwData, // pointer to value data
- sizeof(DWORD))) // length of value data
+ winerrno = RegSetValueEx(hk, // subkey handle
+ "TypesSupported", // value name
+ 0, // must be zero
+ REG_DWORD, // value type
+ (LPBYTE) &dwData, // pointer to value data
+ sizeof(DWORD)); // length of value data
+ if (winerrno != ERROR_SUCCESS)
{
- winerrno = GetLastError();
::syslog(LOG_ERR, "Failed to set the supported types: %s",
GetErrorMessage(winerrno).c_str());
RegCloseKey(hk);
@@ -1384,14 +1384,14 @@
// Set the category message file and number of categories.
- if (RegSetValueExW(hk, // subkey handle
- L"CategoryMessageFile", // value name
- 0, // must be zero
- REG_EXPAND_SZ, // value type
- (LPBYTE)cmd, // pointer to value data
- len*sizeof(WCHAR))) // data size
+ winerrno = RegSetValueExW(hk, // subkey handle
+ L"CategoryMessageFile", // value name
+ 0, // must be zero
+ REG_EXPAND_SZ, // value type
+ (LPBYTE)cmd, // pointer to value data
+ len*sizeof(WCHAR)); // data size
+ if (winerrno != ERROR_SUCCESS)
{
- winerrno = GetLastError();
::syslog(LOG_ERR, "Failed to set the category message file: "
"%s", GetErrorMessage(winerrno).c_str());
RegCloseKey(hk);
@@ -1398,14 +1398,14 @@
return FALSE;
}
- if (RegSetValueEx(hk, // subkey handle
+ winerrno = RegSetValueEx(hk, // subkey handle
"CategoryCount", // value name
0, // must be zero
REG_DWORD, // value type
(LPBYTE) &dwNum, // pointer to value data
- sizeof(DWORD))) // length of value data
+ sizeof(DWORD)); // length of value data
+ if (winerrno != ERROR_SUCCESS)
{
- winerrno = GetLastError();
::syslog(LOG_ERR, "Failed to set the category count: %s",
GetErrorMessage(winerrno).c_str());
RegCloseKey(hk);
More information about the Boxbackup-commit
mailing list