// Registry Query
// 1
CRegKey regkey;
DWORD dValue;
LPCTSTR lp = "Console \\";
If (regkey. Open (HKEY_CURRENT_USER, lp) = ERROR_SUCCESS) // Open
{
If (regkey. QueryValue (dValue, "WindowSize") = ERROR_SUCCESS) // query
{
Cout <dValue <endl; // output the queried Value
}
Else
{
Cout <"Query Error" <endl;
}
Regkey. Close ();
}
Else
{
Cout <"Open error! "<Endl;
}
CRegKey regkey;
DWORD dwCount = 1024;
Char sValue [1024];
// LPCTSTR sValue; // The type of LPCTSTR is const and cannot be used.
LPCTSTR valueName = "";
LPCTSTR lpstr = "* \ shell \"; // you can only delete the key values under it.
If (regkey. Open (HKEY_CLASSES_ROOT, lpstr) = ERROR_SUCCESS) // Open
{
HKEY hKey;
// LPCTSTR hSubKey;
HKey = HKEY_CLASSES_ROOT;
// HSubKey = "* \ shell \ QQ \\";
: RegDeleteKey (hKey, lpstr );
: RegDeleteValue (hKey ,"");
Regkey. DeleteValue (""); // Delete the default value
// Note: regkey. DeleteValue (valuename );
// Regkey. DeleteSubKey ("command"); // You cannot delete an item that contains a subkey.
Regkey. RecurseDeleteKey ("QQ"); // Delete the item containing the subkey (QQ is the key name)
If (regkey. QueryValue (sValue, valueName, & dwCount) = ERROR_SUCCESS) //
{
Cout <sValue <endl; // output the queried Value
}
Else
{
Cout <"Query Error" <endl;
}
}
Else
{
Cout <"Open error! "<Endl;
}
Regkey. Close ();