From: AlexeyD <da...@us...> - 2005-04-19 10:31:14
|
Update of /cvsroot/tora/tora/windows In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24300/windows Modified Files: cregistry.h resource.h tora.rc cregistry.cpp Log Message: Complete code reformat according to agreed criterias. Code style guidelines specified in README.CODESTYLE Index: resource.h =================================================================== RCS file: /cvsroot/tora/tora/windows/resource.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** resource.h 12 May 2004 19:02:39 -0000 1.2 --- resource.h 19 Apr 2005 10:30:49 -0000 1.3 *************** *** 6,10 **** // Next default values for new objects ! // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS --- 6,10 ---- // Next default values for new objects ! // #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS Index: cregistry.cpp =================================================================== RCS file: /cvsroot/tora/tora/windows/cregistry.cpp,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** cregistry.cpp 18 Feb 2005 17:07:45 -0000 1.5 --- cregistry.cpp 19 Apr 2005 10:30:49 -0000 1.6 *************** *** 9,13 **** OSVERSIONINFO OsVer; GetVersionEx(&OsVer); ! return (OsVer.dwPlatformId == VER_PLATFORM_WIN32_NT)!=0; } --- 9,13 ---- OSVERSIONINFO OsVer; GetVersionEx(&OsVer); ! return (OsVer.dwPlatformId == VER_PLATFORM_WIN32_NT) != 0; } *************** *** 19,38 **** HKEY hKey; DWORD dwFunc; ! LONG lRet; lRet = RegCreateKeyEx( ! hKeyRoot, ! pszSubKey, ! 0, ! (LPTSTR)NULL, ! REG_OPTION_NON_VOLATILE, ! KEY_WRITE, ! (LPSECURITY_ATTRIBUTES)NULL, ! &hKey, ! &dwFunc ! ); - if(lRet==ERROR_SUCCESS) { - RegCloseKey(hKey); hKey = (HKEY)NULL; --- 19,39 ---- HKEY hKey; DWORD dwFunc; ! LONG lRet; lRet = RegCreateKeyEx( ! hKeyRoot, ! pszSubKey, ! 0, ! (LPTSTR)NULL, ! REG_OPTION_NON_VOLATILE, ! KEY_WRITE, ! (LPSECURITY_ATTRIBUTES)NULL, ! &hKey, ! &dwFunc ! ); ! ! if (lRet == ERROR_SUCCESS) ! { RegCloseKey(hKey); hKey = (HKEY)NULL; *************** *** 42,85 **** SetLastError((DWORD)lRet); ! return false; } bool CRegistry::DeleteKey(HKEY hKeyRoot, LPCTSTR pszSubKey) { ! DWORD dwRet=ERROR_SUCCESS; ! if(IsWinNTor2K()) { // WinNT/2K will not allow you to delete keys which have // subkeys/values inside them. MS's platform SDK tells you // to use the SHDeleteKey function in shlwapi.dll. This dll // is not available on NT platforms without IE 4.0 or later. ! // Because of this I first attempt to delete the key in the // hope that it is empty. If that is not possible I load shlwapi // and call the function in that. This prevents the app bombing // out if the dll can't be found. ! if(RegDeleteKey(hKeyRoot, pszSubKey)!=ERROR_SUCCESS) { ! HINSTANCE hLibInst = LoadLibrary(_T("shlwapi.dll")); ! ! if(!hLibInst) { throw ERROR_NO_SHLWAPI_DLL; } ! #if defined(UNICODE) || defined(_UNICODE) SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyW"); #else SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyA"); #endif ! if(!DeleteKeyRecursive) { FreeLibrary(hLibInst); throw ERROR_NO_SHDELETEKEY; } ! dwRet = DeleteKeyRecursive(hKeyRoot, pszSubKey); ! FreeLibrary(hLibInst); } } ! else { // Windows 9x will allow RegDeleteKey to delete keys // even if they have subkeys/values. --- 43,93 ---- SetLastError((DWORD)lRet); ! return false; } bool CRegistry::DeleteKey(HKEY hKeyRoot, LPCTSTR pszSubKey) { ! DWORD dwRet = ERROR_SUCCESS; ! if (IsWinNTor2K()) ! { // WinNT/2K will not allow you to delete keys which have // subkeys/values inside them. MS's platform SDK tells you // to use the SHDeleteKey function in shlwapi.dll. This dll // is not available on NT platforms without IE 4.0 or later. ! // Because of this I first attempt to delete the key in the // hope that it is empty. If that is not possible I load shlwapi // and call the function in that. This prevents the app bombing // out if the dll can't be found. ! if (RegDeleteKey(hKeyRoot, pszSubKey) != ERROR_SUCCESS) ! { ! HINSTANCE hLibInst = LoadLibrary(_T("shlwapi.dll")); ! ! if (!hLibInst) ! { throw ERROR_NO_SHLWAPI_DLL; } ! #if defined(UNICODE) || defined(_UNICODE) SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyW"); #else + SHDELKEYPROC DeleteKeyRecursive = (SHDELKEYPROC)GetProcAddress(hLibInst, "SHDeleteKeyA"); #endif ! ! if (!DeleteKeyRecursive) ! { FreeLibrary(hLibInst); throw ERROR_NO_SHDELETEKEY; } ! dwRet = DeleteKeyRecursive(hKeyRoot, pszSubKey); ! FreeLibrary(hLibInst); } } ! else ! { // Windows 9x will allow RegDeleteKey to delete keys // even if they have subkeys/values. *************** *** 87,95 **** } ! if(dwRet == ERROR_SUCCESS) return true; ! SetLastError(dwRet); ! return false; } --- 95,103 ---- } ! if (dwRet == ERROR_SUCCESS) return true; ! SetLastError(dwRet); ! return false; } *************** *** 100,104 **** LONG lRes; ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_SET_VALUE, &hKey))!=ERROR_SUCCESS) { SetLastError((DWORD)lRes); return false; --- 108,113 ---- LONG lRes; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_SET_VALUE, &hKey)) != ERROR_SUCCESS) ! { SetLastError((DWORD)lRes); return false; *************** *** 106,113 **** lRes = RegDeleteValue(hKey, pszValue); ! RegCloseKey(hKey); ! if(lRes==ERROR_SUCCESS) return true; --- 115,122 ---- lRes = RegDeleteValue(hKey, pszValue); ! RegCloseKey(hKey); ! if (lRes == ERROR_SUCCESS) return true; *************** *** 120,129 **** bool CRegistry::GetBinaryValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, PVOID pBuffer, DWORD& rdwSize) { ! HKEY hKey; DWORD dwType = REG_BINARY; DWORD dwSize = rdwSize; ! LONG lRes = 0; ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey))!=ERROR_SUCCESS) { SetLastError((DWORD)lRes); return false; --- 129,139 ---- bool CRegistry::GetBinaryValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, PVOID pBuffer, DWORD& rdwSize) { ! HKEY hKey; DWORD dwType = REG_BINARY; DWORD dwSize = rdwSize; ! LONG lRes = 0; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) ! { SetLastError((DWORD)lRes); return false; *************** *** 131,147 **** lRes = RegQueryValueEx(hKey, pszValue, 0, &dwType, (LPBYTE)pBuffer, &dwSize); ! ! rdwSize = dwSize; RegCloseKey(hKey); ! ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! if(dwType!=REG_BINARY) { throw ERROR_WRONG_TYPE; } ! return true; } --- 141,159 ---- lRes = RegQueryValueEx(hKey, pszValue, 0, &dwType, (LPBYTE)pBuffer, &dwSize); ! ! rdwSize = dwSize; RegCloseKey(hKey); ! ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! if (dwType != REG_BINARY) ! { throw ERROR_WRONG_TYPE; } ! return true; } *************** *** 151,174 **** { HKEY hKey; ! DWORD dwType = REG_DWORD; ! DWORD dwSize = sizeof(DWORD); DWORD dwValue = 0; ! LONG lRes; rdwBuff = 0; ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey))!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! ! lRes = RegQueryValueEx(hKey, pszValue, 0, &dwType, (LPBYTE)&dwValue, &dwSize); ! RegCloseKey(hKey); ! ! if(dwType!=REG_DWORD) throw ERROR_WRONG_TYPE; ! ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; --- 163,188 ---- { HKEY hKey; ! DWORD dwType = REG_DWORD; ! DWORD dwSize = sizeof(DWORD); DWORD dwValue = 0; ! LONG lRes; rdwBuff = 0; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! ! lRes = RegQueryValueEx(hKey, pszValue, 0, &dwType, (LPBYTE) & dwValue, &dwSize); ! RegCloseKey(hKey); ! ! if (dwType != REG_DWORD) throw ERROR_WRONG_TYPE; ! ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; *************** *** 176,180 **** rdwBuff = dwValue; ! return true; } --- 190,194 ---- rdwBuff = dwValue; ! return true; } *************** *** 188,202 **** HKEY hKey; DWORD dwType = REG_SZ; ! LONG lRes; DWORD dwBufferSize = rdwSize; ! if(!pszBuffer) throw ERROR_INVALID_BUFFER; ! if((lRes=RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey))!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! lRes = RegQueryValueEx(hKey, pszValue, NULL, &dwType, (unsigned char*)pszBuffer, &dwBufferSize); --- 202,217 ---- HKEY hKey; DWORD dwType = REG_SZ; ! LONG lRes; DWORD dwBufferSize = rdwSize; ! if (!pszBuffer) throw ERROR_INVALID_BUFFER; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_READ, &hKey)) != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! lRes = RegQueryValueEx(hKey, pszValue, NULL, &dwType, (unsigned char*)pszBuffer, &dwBufferSize); *************** *** 204,212 **** rdwSize = dwBufferSize; ! if(dwType!=REG_SZ) throw ERROR_WRONG_TYPE; ! ! ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; --- 219,228 ---- rdwSize = dwBufferSize; ! if (dwType != REG_SZ) throw ERROR_WRONG_TYPE; ! ! ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; *************** *** 220,239 **** { HKEY hKey; ! LONG lRes = 0; ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey))!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! lRes = RegSetValueEx(hKey, pszValue, 0, REG_BINARY, reinterpret_cast<BYTE*>(pData), dwSize); ! RegCloseKey(hKey); ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! return true; } --- 236,257 ---- { HKEY hKey; ! LONG lRes = 0; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey)) != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! lRes = RegSetValueEx(hKey, pszValue, 0, REG_BINARY, reinterpret_cast<BYTE*>(pData), dwSize); ! RegCloseKey(hKey); ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! return true; } *************** *** 245,263 **** LONG lRes; ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey))!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! ! lRes = RegSetValueEx(hKey, pszValue,0,REG_DWORD,reinterpret_cast<BYTE*>(&dwValue),sizeof(DWORD)); ! RegCloseKey(hKey); ! ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! return true; } --- 263,283 ---- LONG lRes; ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey)) != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! ! lRes = RegSetValueEx(hKey, pszValue, 0, REG_DWORD, reinterpret_cast<BYTE*>(&dwValue), sizeof(DWORD)); ! RegCloseKey(hKey); ! ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! return true; } *************** *** 265,287 **** bool CRegistry::SetStringValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, LPCTSTR pszString) { ! HKEY hKey; ! LONG lRes; DWORD dwSize = lstrlen(pszString) * sizeof(TCHAR); ! if((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey))!=ERROR_SUCCESS) { SetLastError(lRes); return false; ! } ! lRes = RegSetValueEx(hKey, pszValue, 0, REG_SZ, ! (BYTE*)(pszString), dwSize); ! RegCloseKey(hKey); ! if(lRes!=ERROR_SUCCESS) { SetLastError(lRes); return false; } ! return true; ! } \ No newline at end of file --- 285,309 ---- bool CRegistry::SetStringValue(HKEY hKeyRoot, LPCTSTR pszSubKey, LPCTSTR pszValue, LPCTSTR pszString) { ! HKEY hKey; ! LONG lRes; DWORD dwSize = lstrlen(pszString) * sizeof(TCHAR); ! if ((lRes = RegOpenKeyEx(hKeyRoot, pszSubKey, 0, KEY_WRITE, &hKey)) != ERROR_SUCCESS) ! { SetLastError(lRes); return false; ! } ! lRes = RegSetValueEx(hKey, pszValue, 0, REG_SZ, ! (BYTE*)(pszString), dwSize); ! RegCloseKey(hKey); ! if (lRes != ERROR_SUCCESS) ! { SetLastError(lRes); return false; } ! return true; ! } Index: tora.rc =================================================================== RCS file: /cvsroot/tora/tora/windows/tora.rc,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** tora.rc 18 Feb 2005 17:07:45 -0000 1.3 --- tora.rc 19 Apr 2005 10:30:49 -0000 1.4 *************** *** 3,7 **** #include "resource.h" ! #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // --- 3,7 ---- #include "resource.h" ! #define APSTUDIO_READONLY_SYMBOLS ///////////////////////////////////////////////////////////////////////////// // *************** *** 17,21 **** #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) ! #ifdef _WIN32 //LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) --- 17,21 ---- #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) ! #ifdef _WIN32 //LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US #pragma code_page(1252) *************** *** 29,33 **** // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. ! ID_MAIN ICON DISCARDABLE "tora.ico" ///////////////////////////////////////////////////////////////////////////// --- 29,33 ---- // Icon with lowest ID value placed first to ensure application icon // remains consistent on all systems. ! ID_MAIN ICON DISCARDABLE "tora.ico" ///////////////////////////////////////////////////////////////////////////// *************** *** 37,53 **** #ifdef APSTUDIO_INVOKED ! GUIDELINES DESIGNINFO DISCARDABLE BEGIN ! IDD_DIALOG1, DIALOG ! BEGIN ! LEFTMARGIN, 7 ! RIGHTMARGIN, 179 ! TOPMARGIN, 7 ! BOTTOMMARGIN, 88 ! END END #endif // APSTUDIO_INVOKED ! #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// --- 37,53 ---- #ifdef APSTUDIO_INVOKED ! GUIDELINES DESIGNINFO DISCARDABLE BEGIN ! IDD_DIALOG1, DIALOG ! BEGIN ! LEFTMARGIN, 7 ! RIGHTMARGIN, 179 ! TOPMARGIN, 7 ! BOTTOMMARGIN, 88 ! END END #endif // APSTUDIO_INVOKED ! #endif // English (U.S.) resources ///////////////////////////////////////////////////////////////////////////// *************** *** 57,66 **** #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE) ! #ifdef _WIN32 //LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT #pragma code_page(1252) #endif //_WIN32 ! #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // --- 57,66 ---- #if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_SVE) ! #ifdef _WIN32 //LANGUAGE LANG_SWEDISH, SUBLANG_DEFAULT #pragma code_page(1252) #endif //_WIN32 ! #ifdef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // *************** *** 68,96 **** // ! 1 TEXTINCLUDE DISCARDABLE BEGIN ! "resource.h\0" END ! 2 TEXTINCLUDE DISCARDABLE BEGIN ! "#include ""afxres.h""\r\n" ! "\0" END ! 3 TEXTINCLUDE DISCARDABLE BEGIN ! "\r\n" ! "\0" END #endif // APSTUDIO_INVOKED ! #endif // Swedish resources ///////////////////////////////////////////////////////////////////////////// ! #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // --- 68,96 ---- // ! 1 TEXTINCLUDE DISCARDABLE BEGIN ! "resource.h\0" END ! 2 TEXTINCLUDE DISCARDABLE BEGIN ! "#include ""afxres.h""\r\n" ! "\0" END ! 3 TEXTINCLUDE DISCARDABLE BEGIN ! "\r\n" ! "\0" END #endif // APSTUDIO_INVOKED ! #endif // Swedish resources ///////////////////////////////////////////////////////////////////////////// ! #ifndef APSTUDIO_INVOKED ///////////////////////////////////////////////////////////////////////////// // Index: cregistry.h =================================================================== RCS file: /cvsroot/tora/tora/windows/cregistry.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** cregistry.h 12 May 2004 19:02:39 -0000 1.2 --- cregistry.h 19 Apr 2005 10:30:48 -0000 1.3 *************** *** 20,25 **** #include <tchar.h> ! const unsigned int ERROR_WRONG_TYPE = 0x01; // Wrong type of data ! const unsigned int ERROR_BUFFER_SIZE = 0x02; // Buffer too small const unsigned int ERROR_NO_SHLWAPI_DLL = 0x03; // Only under NT if shlwapi.dll doesn't exist const unsigned int ERROR_INVALID_BUFFER = 0x04; // Occurs if buffer invalid (ie no buffer) --- 20,25 ---- #include <tchar.h> ! const unsigned int ERROR_WRONG_TYPE = 0x01; // Wrong type of data ! const unsigned int ERROR_BUFFER_SIZE = 0x02; // Buffer too small const unsigned int ERROR_NO_SHLWAPI_DLL = 0x03; // Only under NT if shlwapi.dll doesn't exist const unsigned int ERROR_INVALID_BUFFER = 0x04; // Occurs if buffer invalid (ie no buffer) *************** *** 28,32 **** typedef DWORD (__stdcall* SHDELKEYPROC)(HKEY, LPCTSTR); ! class CRegistry { bool IsWinNTor2K(); public: --- 28,33 ---- typedef DWORD (__stdcall* SHDELKEYPROC)(HKEY, LPCTSTR); ! class CRegistry ! { bool IsWinNTor2K(); public: *************** *** 42,44 **** }; ! #endif \ No newline at end of file --- 43,45 ---- }; ! #endif |