社区
界面
帖子详情
怎么删除一个嵌套多层的注册表项啊??
chen_chen1212
2008-08-19 10:49:57
怎么删除一个嵌套多层的注册表项啊??我要把这个注册表项都删除掉??
...全文
130
2
打赏
收藏
怎么删除一个嵌套多层的注册表项啊??
怎么删除一个嵌套多层的注册表项啊??我要把这个注册表项都删除掉??
复制链接
扫一扫
分享
转发到动态
举报
AI
作业
写回复
配置赞助广告
用AI写文章
2 条
回复
切换为时间正序
请发表友善的回复…
发表回复
打赏红包
王晓华-吹泡泡的小猫
2008-08-19
打赏
举报
回复
#include <windows.h>
#include <stdio.h>
#include <strsafe.h>
//*************************************************************
//
// 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 {
StringCchCopy (lpEnd, MAX_PATH*2, 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;
}
//*************************************************************
//
// RegDelnode()
//
// 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 RegDelnode (HKEY hKeyRoot, LPTSTR lpSubKey)
{
TCHAR szDelKey[2 * MAX_PATH];
StringCchCopy (szDelKey, MAX_PATH*2, lpSubKey);
return RegDelnodeRecurse(hKeyRoot, szDelKey);
}
void main()
{
BOOL bSuccess;
bSuccess = RegDelnode(HKEY_CURRENT_USER,
TEXT("Software\\TestDir"));
if(bSuccess)
printf("Success!\n");
else printf("Failure.\n");
}
yuzhongzhu
2008-08-19
打赏
举报
回复
递归删除,搜下吧,代码好像很多的
注册表
基本知识
2. **支持子键:**
注册表
支持
多层
嵌套
的键(Key),每个键都可以包含自己的子键和值,形成了
一个
层次分明的数据结构。 3. **包含可执行代码:** 键值可以包含可执行代码,而不仅仅是简单的字符串,这为应用程序提供...
killbox
删除
任意文件
提供的"说明.txt"文件可能包含有关如何使用KillBox的详细指南,包括更复杂的操作,如
删除
注册表
项
或处理
多层
嵌套
的恶意程序。 总的来说,KillBox是一款强大的文件
删除
工具,对于处理常规方法难以移除的文件非常有用...
AutoIt入门与提高.pdf
- **写入
注册表
**:利用`RegWrite`函数修改
注册表
项
。 ### 第六章 文件读写 - **Ini配置文件读写**:使用`FileIniRead`和`FileIniWrite`函数操作Ini文件。 - **Txt文档读写**:通过`FileOpen`、`FileRead`和`File...
Oracle课程目录
- **卸载过程**:介绍如何彻底卸载Oracle数据库,包括清除残留文件和
注册表
项
。 - **环境配置**:教授如何根据实际需求调整Oracle环境配置,如参数文件(spfile和pfile)的配置方法。 - **优化技巧**:分享提高...
界面
15,980
社区成员
115,867
社区内容
发帖
与我相关
我的任务
界面
VC/MFC 界面
复制链接
扫一扫
分享
社区描述
VC/MFC 界面
社区管理员
加入社区
获取链接或二维码
近7日
近30日
至今
加载中
查看更多榜单
社区公告
暂无公告
试试用AI创作助手写篇文章吧
+ 用AI写文章