用了SHDeleteKey RegDeleteTree等函数 都无法删除注册表里的值
这是什么原因呢?
防火墙啥的肯定没有禁注册表
下边是我的代码:HKEY hkey;
//RegCreateKey(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", &hkey);
//RegSetValue(hkey, NULL, REG_SZ,"abc",strlen("abc"));
RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", &hkey);
SHDeleteKey(hkey, "Software\\http://www.vcpp.com");
RegCloseKey(hkey);
这是什么原因呢?
防火墙啥的肯定没有禁注册表
下边是我的代码:HKEY hkey;
//RegCreateKey(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", &hkey);
//RegSetValue(hkey, NULL, REG_SZ,"abc",strlen("abc"));
RegOpenKey(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", &hkey);
SHDeleteKey(hkey, "Software\\http://www.vcpp.com");
RegCloseKey(hkey);
直接用RegDeleteKey一层一层的删呢
但是就是运行了没效果
LONG WINAPI RegOpenKey(
__in HKEY hKey,
__in LPCTSTR lpSubKey,
__out PHKEY phkResult
);
那个地方给权限啊?
HKEY hkey;
RegCreateKey(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", &hkey);
RegCreateKeyEx(HKEY_LOCAL_MACHINE, "Software\\http://www.vcpp.com\\admin", 0, NULL,
REG_OPTION_VOLATILE,KEY_ALL_ACCESS, NULL, &hkey, NULL); RegOpenKeyEx(HKEY_LOCAL_MACHINE,"Software\\http://www.vcpp.com\\admin", 0, KEY_ALL_ACCESS, &hkey);
RegDeleteKey(hkey, "Software\\http://www.vcpp.com\\admin"); RegCloseKey(hkey);这么写了还是不行
//
// RegDelnodeRecurse()
//
// Purpose: Deletes a registry key and all it's subkeys / values.
//
// Parameters: hKeyRoot - Root key
// lpSubKey - SubKey to delete
//
// Return: TRUE if successful.
// FALSE if an error occurs.
//
//*************************************************************BOOL RegDelnodeRecurse (HKEY hKeyRoot, LPTSTR lpSubKey)
{
LPTSTR lpEnd;
LONG lResult;
DWORD dwSize;
TCHAR szName[MAX_PATH];
HKEY hKey;
FILETIME ftWrite; // First, see if we can delete the key without having
// to recurse. lResult = RegDeleteKey(hKeyRoot, lpSubKey); if (lResult == ERROR_SUCCESS)
return TRUE; lResult = RegOpenKeyEx (hKeyRoot, lpSubKey, 0, KEY_READ, &hKey); if (lResult != ERROR_SUCCESS)
{
if (lResult == ERROR_FILE_NOT_FOUND) {
printf("Key not found.\n");
return TRUE;
}
else {
printf("Error opening key.\n");
return FALSE;
}
} // Check for an ending slash and add one if it is missing. lpEnd = lpSubKey + lstrlen(lpSubKey); if (*(lpEnd - 1) != TEXT('\\'))
{
*lpEnd = TEXT('\\');
lpEnd++;
*lpEnd = TEXT('\0');
} // Enumerate the keys dwSize = MAX_PATH;
lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
NULL, NULL, &ftWrite); if (lResult == ERROR_SUCCESS)
{
do { lstrcpy (lpEnd, szName); if (!RegDelnodeRecurse(hKeyRoot, lpSubKey)) {
break;
} dwSize = MAX_PATH; lResult = RegEnumKeyEx(hKey, 0, szName, &dwSize, NULL,
NULL, NULL, &ftWrite); } while (lResult == ERROR_SUCCESS);
} lpEnd--;
*lpEnd = TEXT('\0'); RegCloseKey (hKey); // Try again to delete the key. lResult = RegDeleteKey(hKeyRoot, lpSubKey); if (lResult == ERROR_SUCCESS)
return TRUE; return FALSE;
}