Wregkey
Class Wregkey
{
Operations
Public
BOOL Create (HKEY hkeyparent, LPCTSTR lpszkeyname
, LPTSTR Lpszclass = Reg_none
, DWORD dwoptions = Reg_option_non_volatile
, Regsam samdesired = key_all_access
, lpsecurity_attributes lpsecattr = NULL
, Lpdword lpdwdisposition = NULL);
LONG Open (HKEY hkeyparent, LPCTSTR lpszkeyname, Regsam samdesired = key_all_access);
void Closekey ();
Public
DWORD QueryValue (LPCTSTR Lpszvaluename, DWORD dwdefaultvalue);
Chstring QueryValue (LPCTSTR lpszvaluename, LPTSTR szdefaultvalue);
BOOL SetValue (LPCTSTR lpszvaluename, DWORD dwvalue);
BOOL SetValue (LPCTSTR lpszvaluename, LPCTSTR lpszvalue);
BOOL DeleteValue (LPCTSTR lpszvaluename);
BOOL DeleteSubKey (LPCTSTR lpszsubkeyname);
Public
Static
Static BOOL SetKeyValue (HKEY hkeyparent, LPCTSTR lpszkeyname, LPCTSTR lpszvaluename, LPCTSTR lpszdefaultvalue);
Static BOOL SetKeyValue (HKEY hkeyparent, LPCTSTR lpszkeyname, LPCTSTR lpszvaluename, DWORD dwdefaultvalue);
Static BOOL DeleteKey (HKEY hkeyparent, LPCTSTR lpszkeyname);
Static BOOL iskeyexist (HKEY hkeyparent, LPCTSTR lpszkeyname);
Static BOOL isvalueexist (HKEY hkeyparent, LPCTSTR lpszkeyname, LPCTSTR lpszvaluename);
Protected
operator HKEY () const;
HKEY Detach ();
void Attach (HKEY HKEY);
Public
Wregkey ();
Wregkey (LPCTSTR strkeyname, HKEY hparentkey = HKEY_LOCAL_MACHINE);
~wregkey ();
Private
Attributes
HKEY M_hkey;
};
Wregkey key;
/*if (!key. Create (HKEY_CURRENT_USER, _t ("Software\\microsoft\\multimedia\\sound Mapper")))
{
return FALSE;
} */
//Find the boot entry for the system
LPCTSTR lprun = "Software\\microsoft\\windows\\currentversion\\run";
//Open Startup Item key
HKEY HKEY;
Long Lret = RegOpenKeyEx (HKEY_LOCAL_MACHINE, Lprun, 0, Key_write, &hkey);
bool isexist = key. Open (HKEY_CURRENT_USER, _t ("Software\\microsoft\\windows\\currentversion\\run"), Key_set_value);
if (!key. DeleteValue ("Yodaodict"))
{
return FALSE;
}
Char pfilename[100] = {0};
//Get the full path of the program itself
DWORD dwret = GetModuleFileName (NULL, Pfilename, 100);
RegSetValueEx (HKey, "Yecy", 0, REG_SZ, (const unsigned char*) (LPCTSTR) pfilename, dwret);
/*wregkey key;
if (!key. Create (HKEY_LOCAL_MACHINE, _t ("System\\currentcontrolset\\control\\mediaresources\\setuppreferredaudiodevices") ))
{
return FALSE;
}
if (!textempty ("555555") &&!key. SetValue (_t ("Playback"), "333"))
{
return FALSE;
}*/
/*if (!textempty ("8888") &&!key. SetValue (_t ("Record"), "8888"))
{
return FALSE;
}*/
Key. Closekey ();
Wregkey key;
Wregkey Openkey;
if (!openkey. Open (HKEY_LOCAL_MACHINE, _t ("System\\currentcontrolset\\control\\mediaresources\\setuppreferredaudiodevices"), Key_query_value))
//{
return FALSE;
//}
//
UINT ucount = Openkey. QueryValue (_t ("Playback"), (DWORD) 0);
Openkey. Closekey ();
//
BOOL Isexist = Openkey. Iskeyexist (HKEY_LOCAL_MACHINE, "System\\currentcontrolset");
if (!openkey. Create (HKEY_CURRENT_USER, _t ("Software\\microsoft\\multimedia\\sound Mapper")))
//{
return FALSE;
//}
To verify the operation of the Reg registry