【发布时间】:2012-03-22 18:37:12
【问题描述】:
我想从我的控制面板编辑注册表值中禁用Device Manager。我可以在 C# 中完成,但我想在 C++ 中完成,而不使用任何 .NET 框架。我已经成功地在 C++ 中更改了我的处理器名称。但是当我想禁用任务管理器时我遇到了问题。这是我的代码。
HKEY hKey;
RegOpenKeyEx(HKEY_LOCAL_MACHINE,
"HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0",
0,
KEY_SET_VALUE,
&hKey);
RegSetValueEx(hKey, REGNAME_TO_WRITE, 0, REG_SZ,
(const unsigned char *)"ProcessorNameString",
strlen("ProcessorNameString"));
//RegCloseKey(hKey);
// The problem begins here
RegOpenKeyEx( HKEY_LOCAL_MACHINE,
"Software\\Policies\\Microsoft\MMC\\{74246bfc-4c96-11d0-abef-0020af6b0b7a}\\",
0,
KEY_SET_VALUE,
&hKey );
RegSetValueEx( hKey,"Restrict_Run",0,REG_SZ,
(const unsigned char *)"1",
strlen("1") );
RegCloseKey(hKey);
return 0;
}
【问题讨论】:
-
什么版本的 Windows?什么处理器架构?也许您正在运行 32 位代码并更改注册表的 32 位视图(WOW64 重定向),但 Windows 正在查看 64 位注册表。
-
我使用的是 windows 7 专业版 32 位。