Visual c++ 如何从vc++;编码
我在注册表名我的\u软件中有一个项 我想从vc++编码中删除它Visual c++ 如何从vc++;编码,visual-c++,registry,Visual C++,Registry,我在注册表名我的\u软件中有一个项 我想从vc++编码中删除它 CRegKey key; LPCSTR lpszKey = "SOFTWARE\\my_software"; key.m_hKey = HKEY_LOCAL_MACHINE; LONG lRes = key.Open(key.m_hKey, lpszKey); LONG err = key.DeleteSubKey(lpszKey); 调试代码时,err的值为0x00000002。 当我在winerror.h文件中看到时,它意味
CRegKey key;
LPCSTR lpszKey = "SOFTWARE\\my_software";
key.m_hKey = HKEY_LOCAL_MACHINE;
LONG lRes = key.Open(key.m_hKey, lpszKey);
LONG err = key.DeleteSubKey(lpszKey);
调试代码时,err的值为0x00000002。
当我在winerror.h文件中看到时,它意味着找不到错误文件,如下所示:
bool DeleteValueKey(HKEY hKeyRoot, std::string Subkey, std::string ValueKey)
{
HKEY hKey = NULL;
bool bReturn = false;
if (RegOpenKeyEx(hKeyRoot, Subkey.c_str(), 0, KEY_SET_VALUE , &hKey) == ERROR_SUCCESS)
{
if (RegDeleteKey(hKey, ValueKey.c_str() ) == ERROR_SUCCESS)
{
bReturn = true;
}
}
if(hKey != NULL){RegCloseKey(hKey);}
return bReturn;
}
用法:DeleteValueKey(HKEY_本地_机器,“软件\我的_软件”,“文件夹”);