+#include <defines.h>
+#include <reactos/resource.h>
+
//Microsoft Developer Studio generated resource script.
//
#include "resource.h"
// Accelerator
//
+#ifdef _MSC_VER
IDR_ACCELERATOR ACCELERATORS DISCARDABLE
BEGIN
VK_F2, ID_VIEW_DEGREES, VIRTKEY, NOINVERT
VK_F7, ID_VIEW_OCTAL, VIRTKEY, NOINVERT
VK_F8, ID_VIEW_BINARY, VIRTKEY, NOINVERT
END
+#endif // _MSC_VER
+
+
+/////////////////////////////////////////////////////////////////////////////
+//
+// Version
+//
+
+VS_VERSION_INFO VERSIONINFO
+ FILEVERSION RES_UINT_FV_MAJOR,RES_UINT_FV_MINOR,RES_UINT_FV_REVISION,RES_UINT_FV_BUILD
+ PRODUCTVERSION RES_UINT_PV_MAJOR,RES_UINT_PV_MINOR,RES_UINT_PV_REVISION,RES_UINT_PV_BUILD
+ FILEFLAGSMASK 0x3fL
+#ifdef _DEBUG
+ FILEFLAGS 0x1L
+#else
+ FILEFLAGS 0x0L
+#endif
+ FILEOS 0x40004L
+ FILETYPE 0x1L
+ FILESUBTYPE 0x0L
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904b0"
+ BEGIN
+ VALUE "Comments", "Absolutely no warranties whatsoever - Use at your own risk\0"
+ VALUE "CompanyName", RES_STR_COMPANY_NAME
+ VALUE "FileDescription", "ReactOS Calculator by Robert Dickenson\0"
+ VALUE "FileVersion", "1, 0, 0, 1\0"
+ VALUE "InternalName", "calc\0"
+ VALUE "LegalCopyright", "Copyright © 2002 Robert Dickenson\0"
+ VALUE "LegalTrademarks", "\0"
+ VALUE "OriginalFilename", "calc.exe\0"
+ VALUE "PrivateBuild", "\0"
+ VALUE "ProductName", RES_STR_PRODUCT_NAME
+ VALUE "ProductVersion", RES_STR_PRODUCT_VERSION
+ VALUE "SpecialBuild", "Non-versioned Development Beta Release\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0xc09, 1200
+ END
+END
/////////////////////////////////////////////////////////////////////////////
STRINGTABLE DISCARDABLE
BEGIN
IDS_APP_TITLE "ReactOS Calculator"
+ IDS_APP_REG_KEY "\\Calculator"
+ IDS_APP_REG_PATH RES_STR_ROSAPP_REGISTRY_ROOT
+
END
#endif // English (Australia) resources
#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#include <windows.h>
#include <tchar.h>
+#include <assert.h>
+#define ASSERT assert
#include "main.h"
#include "settings.h"
-BOOL CheckResult(LONG error)
+static BOOL CheckResult(LONG error)
{
if (error != ERROR_SUCCESS) {
PTSTR msg;
return TRUE;
}
+static BOOL CreateRegistryPath(LPTSTR szRegPath, int nMaxLen)
+{
+ LPTSTR pRegPath = szRegPath;
+
+ // Initialise registry path string from application PATH and KEY resources
+ int nLength = LoadString(hInst, IDS_APP_REG_PATH, szRegPath, nMaxLen);
+ nLength += LoadString(hInst, IDS_APP_REG_KEY, szRegPath + nLength, nMaxLen - nLength);
+ ASSERT(nLength < (nMaxLen - 1));
+ szRegPath[nLength] = _T('\\');
+
+ // walk the registry path string creating the tree if required
+ while (pRegPath = _tcschr(pRegPath, _T('\\'))) {
+ LONG result;
+ HKEY hKey = NULL;
+ *pRegPath = _T('\0');
+ // Open (or create) the key
+ result = RegCreateKeyEx(HKEY_CURRENT_USER, szRegPath, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
+ if (!CheckResult(result)) return FALSE;
+ RegCloseKey(hKey);
+ *pRegPath = _T('\\');
+ pRegPath = pRegPath + 1;
+ }
+ szRegPath[nLength] = _T('\0');
+ return TRUE;
+}
+
void LoadSettings(void)
{
+ TCHAR szRegPath[MAX_LOADSTRING];
+
HKEY hKey;
DWORD dwSize;
LONG result;
- char szSubKey[] = "Software\\ReactWare\\Calculator";
+
+ if (!CreateRegistryPath(szRegPath, MAX_LOADSTRING)) return;
// Open the key
- result = RegOpenKeyEx(HKEY_CURRENT_USER, szSubKey, 0, KEY_READ, &hKey);
+ result = RegOpenKeyEx(HKEY_CURRENT_USER, szRegPath, 0, KEY_READ, &hKey);
if (!CheckResult(result)) return;
// Read the settings
dwSize = sizeof(CALC_TYPES);
result = RegQueryValueEx(hKey, _T("Preferences"), NULL, NULL, (LPBYTE)&CalcType, &dwSize);
- if (!CheckResult(result)) goto abort;
-abort:
// Close the key
RegCloseKey(hKey);
}
void SaveSettings(void)
{
- HKEY hKey;
- LONG result;
- char szSubKey1[] = "Software";
- char szSubKey2[] = "Software\\ReactWare";
- char szSubKey3[] = "Software\\ReactWare\\Calculator";
+ TCHAR szRegPath[MAX_LOADSTRING];
+ HKEY hKey = NULL;
+ LONG result;
- // Open (or create) the key
- hKey = NULL;
- result = RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey1, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
- if (!CheckResult(result)) return;
- RegCloseKey(hKey);
- hKey = NULL;
- result = RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey2, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
- if (!CheckResult(result)) return;
- RegCloseKey(hKey);
- hKey = NULL;
- result = RegCreateKeyEx(HKEY_CURRENT_USER, szSubKey3, 0, NULL, REG_OPTION_NON_VOLATILE, KEY_WRITE, NULL, &hKey, NULL);
+ if (!CreateRegistryPath(szRegPath, MAX_LOADSTRING)) return;
+
+ // Open the key
+ result = RegOpenKeyEx(HKEY_CURRENT_USER, szRegPath, 0, KEY_WRITE, &hKey);
if (!CheckResult(result)) return;
// Save the settings