CodeBlocks 使用 VC2010 编译器,需要指定 AdvAPI32.lib
库编译完成
直接删除注册表中某个目录,踩坑两次 注意 "\" 符号
#include <stdio.h>
#include <windows.h>
int main()
{
HKEY hKey = HKEY_CURRENT_USER;
const char* SubKey = "Software\\VB and VBA Program Settings\\sRGB";
int ret = RegDeleteTreeA(hKey, SubKey);
return ret;
}
// https://docs.microsoft.com/zh-cn/windows/win32/api/winreg/nf-winreg-regdeletekeyvaluea
//LSTATUS RegDeleteKeyA(
// HKEY hKey,
// LPCSTR lpSubKey
//);
//LSTATUS RegDeleteTreeA(
// HKEY hKey,
// LPCSTR lpSubKey
//);
//LSTATUS RegDeleteKeyValueA(
// HKEY hKey,
// LPCSTR lpSubKey,
// LPCSTR lpValueName
//);
// #define HKEY_CLASSES_ROOT ((HKEY) (ULONG_PTR)((LONG)0x80000000))
// #define HKEY_CURRENT_USER ((HKEY) (ULONG_PTR)((LONG)0x80000001))
// #define HKEY_LOCAL_MACHINE ((HKEY) (ULONG_PTR)((LONG)0x80000002))
// #define HKEY_USERS ((HKEY) (ULONG_PTR)((LONG)0x80000003))
删除某些软件注册信息
#include <stdio.h>
#include <windows.h>
int main()
{
HKEY hKey = HKEY_CURRENT_USER;
const char* SubKey = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion";
const char* ValueName = "REG_KR";
int ret = RegDeleteKeyValueA(hKey, SubKey, ValueName);
return ret;
}