无法删除注册表项

时间:2014-11-27 05:07:35

标签: winapi visual-c++

我创建了一个新的注册表项。我无法删除父节点。注册表结构如下:

HKEY_CURRENT_USER \ Software \ IE_BACKUP \ Internet设置 下面是我用于删除注册表项的代码。它删除了InternetSettings节点的内容,但无法删除IE_BACKUP。

 void main()
 {  //some other stuffs of code are here for creating new registry.
 bool ret = DeleteValueKey(HKEY_CURRENT_USER, L"Software\\IE_BACKUP",L"Internet  Settings");


 }

bool DeleteValueKey(HKEY hKeyRoot, LPCWSTR Subkey, LPCWSTR ValueKey)
{
HKEY    hKey        = NULL;
bool    bReturn     = false;

    if (RegDeleteKey(hKey, Subkey ) == ERROR_SUCCESS)
    {
        bReturn = true;
    }
if (RegOpenKeyEx(hKeyRoot, Subkey, 0, KEY_SET_VALUE , &hKey) == ERROR_SUCCESS)
{                   
   if (RegDeleteKey(hKey, ValueKey ) == ERROR_SUCCESS)
    {
        bReturn = true;
    }
}

if(hKey != NULL){RegCloseKey(hKey);}

return bReturn;
}

0 个答案:

没有答案