REGVARS.CPP
资源名称:pciexp.zip [点击查看]
上传用户:zhuqijet
上传日期:2007-01-04
资源大小:138k
文件大小:4k
源码类别:
驱动编程
开发平台:
Visual C++
- #include "stdafx.h"
- #include "registry.h"
- #include "regvars.h"
- /****************************************************************************
- * RegistryVar::getInt
- * Inputs:
- * UINT id: ID value
- * int def: Default value (= 0)
- * HKEY root: default HKEY_CURRENT_USER
- * Result: int
- *
- * Effect:
- * Retrieves the integer value
- ****************************************************************************/
- int RegistryVar::getInt(UINT id, int def, HKEY root)
- {
- DWORD value;
- CString pathname;
- pathname.LoadString(id);
- if(!GetRegistryInt(root, pathname, value))
- return def;
- return (int)value;
- }
- /****************************************************************************
- * RegistryVar::setInt
- * Inputs:
- * UINT id: ID to set
- * int value: Value to set
- * HKEY root: default HKEY_CURRENT_USER
- * Result: void
- *
- * Effect:
- * Sets the registry key
- ****************************************************************************/
- void RegistryVar::setInt(UINT id, int value, HKEY root)
- {
- CString pathname;
- pathname.LoadString(id);
- SetRegistryInt(root, pathname, value);
- }
- /****************************************************************************
- * RegistryVar::setString
- * Inputs:
- * UINT id: ID of variable in
- * LPCTSTR value: String value to save
- * HKEY root: default HKEY_CURRENT_USER
- * Result: void
- *
- * Effect:
- * Stores the string value in the registry
- ****************************************************************************/
- void RegistryVar::setString(UINT id, LPCTSTR value, HKEY root)
- {
- CString pathname;
- pathname.LoadString(id);
- SetRegistryString(root, pathname, value);
- }
- /****************************************************************************
- * RegistryVar::getString
- * Inputs:
- * UINT id: ID of subkey
- * LPCTSTR def: Default value, or NULL
- * HKEY root: default HKEY_CURRENT_USER
- * Result: CString
- * The string value loaded
- * Effect:
- * Loads the string from the registry
- ****************************************************************************/
- CString RegistryVar::getString(UINT id, LPCTSTR def, HKEY root)
- {
- CString pathname;
- CString value;
- pathname.LoadString(id);
- if(!GetRegistryString(root, pathname, value))
- { /* failed */
- if(def != NULL)
- value = def;
- else
- value = _T("");
- } /* failed */
- return value;
- }
- /****************************************************************************
- * RegistryInt::load
- * Result: BOOL
- * TRUE if loaded successfully
- * FALSE if no load occurred
- * Effect:
- * Loads the 'value'
- ****************************************************************************/
- int RegistryInt::load(int def)
- {
- value = getInt(id, def, root);
- return value;
- }
- /****************************************************************************
- * RegistryInt::store
- * Result: void
- *
- * Effect:
- * Stores the 'value'
- ****************************************************************************/
- void RegistryInt::store()
- {
- setInt(id, value, root);
- }
- /****************************************************************************
- * RegistryString::load
- * Inputs:
- * LPCTSTR def: Default value, or NULL if no default
- * Result: CString
- * The string that was loaded
- * Effect:
- * Loads the string
- ****************************************************************************/
- CString RegistryString::load(LPCTSTR def)
- {
- value = getString(id, def, root);
- return value;
- }
- /****************************************************************************
- * RegistryString::store
- * Result: void
- *
- * Effect:
- * Stores the variable
- ****************************************************************************/
- void RegistryString::store()
- {
- setString(id, (LPCTSTR)value, root);
- }