|
From: <got...@us...> - 2009-09-11 08:00:55
|
Revision: 308
http://scstudio.svn.sourceforge.net/scstudio/?rev=308&view=rev
Author: gotthardp
Date: 2009-09-11 08:00:44 +0000 (Fri, 11 Sep 2009)
Log Message:
-----------
GetRegistryDWORD and SetRegistryDWORD moved from optionsdlg to dllmodule.
Modified Paths:
--------------
trunk/src/view/visio/addon/dllmodule.cpp
trunk/src/view/visio/addon/dllmodule.h
trunk/src/view/visio/addon/optionsdlg.cpp
trunk/src/view/visio/addon/optionsdlg.h
Modified: trunk/src/view/visio/addon/dllmodule.cpp
===================================================================
--- trunk/src/view/visio/addon/dllmodule.cpp 2009-09-11 07:48:48 UTC (rev 307)
+++ trunk/src/view/visio/addon/dllmodule.cpp 2009-09-11 08:00:44 UTC (rev 308)
@@ -77,6 +77,80 @@
return csRet;
}
+class RegistryValueNotFound
+{ };
+
+DWORD GetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter)
+{
+ HKEY hPathKey;
+ if(RegOpenKeyEx(key, subkey, 0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
+ {
+ throw RegistryValueNotFound();
+ }
+
+ DWORD valueType;
+ DWORD value;
+ DWORD valueLength = sizeof(DWORD);
+
+ if(RegQueryValueEx(hPathKey, parameter,
+ NULL, &valueType, (LPBYTE)&value, &valueLength) != ERROR_SUCCESS)
+ {
+ throw RegistryValueNotFound();
+ }
+
+ RegCloseKey(hPathKey);
+ return value;
+}
+
+int SetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter, DWORD value)
+{
+ HKEY hPathKey;
+ if(RegCreateKeyEx(
+ key,
+ subkey,
+ 0,
+ NULL,
+ REG_OPTION_NON_VOLATILE,
+ KEY_ALL_ACCESS,
+ NULL,
+ &hPathKey,
+ NULL) != ERROR_SUCCESS)
+ {
+ return 0;
+ }
+
+ if(RegSetValueEx(hPathKey,
+ parameter,
+ 0, // must be zero
+ REG_DWORD, // value type
+ (LPBYTE)&value, sizeof(DWORD)) != ERROR_SUCCESS)
+ {
+ return 0;
+ }
+
+ RegCloseKey(hPathKey);
+ return 1;
+}
+
+DWORD GetRegistryDWORD(const TCHAR* subkey, const TCHAR* parameter, DWORD default_value)
+{
+ try
+ {
+ return GetRegistryDWORD(HKEY_CURRENT_USER, subkey, parameter);
+ }
+ catch(RegistryValueNotFound)
+ { }
+
+ try
+ {
+ return GetRegistryDWORD(HKEY_LOCAL_MACHINE, subkey, parameter);
+ }
+ catch(RegistryValueNotFound)
+ { }
+
+ return default_value;
+}
+
#ifdef _MANAGED
#pragma managed(push, off)
#endif
Modified: trunk/src/view/visio/addon/dllmodule.h
===================================================================
--- trunk/src/view/visio/addon/dllmodule.h 2009-09-11 07:48:48 UTC (rev 307)
+++ trunk/src/view/visio/addon/dllmodule.h 2009-09-11 08:00:44 UTC (rev 308)
@@ -19,7 +19,12 @@
#pragma once
#include <string>
+#define SCSTUDIO_REGISTRY_ROOT _T("Software\\Sequence Chart Studio")
+
std::wstring LoadStringResource(UINT uiID);
std::wstring GetVersionInfo(const LPWSTR block);
+DWORD GetRegistryDWORD(const TCHAR* subkey, const TCHAR* parameter, DWORD default_value);
+int SetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter, DWORD value);
+
// $Id$
Modified: trunk/src/view/visio/addon/optionsdlg.cpp
===================================================================
--- trunk/src/view/visio/addon/optionsdlg.cpp 2009-09-11 07:48:48 UTC (rev 307)
+++ trunk/src/view/visio/addon/optionsdlg.cpp 2009-09-11 08:00:44 UTC (rev 308)
@@ -17,84 +17,11 @@
*/
#include "stdafx.h"
+#include "dllmodule.h"
#include "optionsdlg.h"
#include "data/prerequisite_check.h"
-class RegistryValueNotFound
-{ };
-
-DWORD GetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter)
-{
- HKEY hPathKey;
- if(RegOpenKeyEx(key, subkey, 0, KEY_READ, &hPathKey) != ERROR_SUCCESS)
- {
- throw RegistryValueNotFound();
- }
-
- DWORD valueType;
- DWORD value;
- DWORD valueLength = sizeof(DWORD);
-
- if(RegQueryValueEx(hPathKey, parameter,
- NULL, &valueType, (LPBYTE)&value, &valueLength) != ERROR_SUCCESS)
- {
- throw RegistryValueNotFound();
- }
-
- RegCloseKey(hPathKey);
- return value;
-}
-
-int SetRegistryDWORD(HKEY key, const TCHAR* subkey, const TCHAR* parameter, DWORD value)
-{
- HKEY hPathKey;
- if(RegCreateKeyEx(
- key,
- subkey,
- 0,
- NULL,
- REG_OPTION_NON_VOLATILE,
- KEY_ALL_ACCESS,
- NULL,
- &hPathKey,
- NULL) != ERROR_SUCCESS)
- {
- return 0;
- }
-
- if(RegSetValueEx(hPathKey,
- parameter,
- 0, // must be zero
- REG_DWORD, // value type
- (LPBYTE)&value, sizeof(DWORD)) != ERROR_SUCCESS)
- {
- return 0;
- }
-
- RegCloseKey(hPathKey);
- return 1;
-}
-
-DWORD GetRegistryDWORD(const TCHAR* subkey, const TCHAR* parameter, DWORD default_value)
-{
- try
- {
- return GetRegistryDWORD(HKEY_CURRENT_USER, subkey, parameter);
- }
- catch(RegistryValueNotFound)
- { }
-
- try
- {
- return GetRegistryDWORD(HKEY_LOCAL_MACHINE, subkey, parameter);
- }
- catch(RegistryValueNotFound)
- { }
-
- return default_value;
-}
-
int COptionsDlg::LoadRegistryData()
{
// (1) load the output level
Modified: trunk/src/view/visio/addon/optionsdlg.h
===================================================================
--- trunk/src/view/visio/addon/optionsdlg.h 2009-09-11 07:48:48 UTC (rev 307)
+++ trunk/src/view/visio/addon/optionsdlg.h 2009-09-11 08:00:44 UTC (rev 308)
@@ -72,10 +72,7 @@
int SaveRegistryData();
};
-#define SCSTUDIO_REGISTRY_ROOT _T("Software\\Sequence Chart Studio")
static const DWORD DEFAULT_CHECKER_PRIORITY = 0;
static const DWORD DEFAULT_OUTPUT_LEVEL = 2;
-DWORD GetRegistryDWORD(const TCHAR* subkey, const TCHAR* parameter, DWORD default_value);
-
// $Id$
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|