|
100精币
本帖最后由 冯古屋 于 2020-1-1 20:00 编辑
#include"stdafx.h"
#define INITGUID
#include<iostream>
#include<Windows.h>
#include<GPEdit.h>
#include<Guiddef.h>
using namespace std;
//本地组策略是否禁用任务管理器
LRESULT DisableTaskMgr(int mark)
{ ::CoInitialize(NULL);
LRESULT status;
LRESULT hr=S_OK;
IGroupPolicyObject*pGPO=NULL;
hr=CoCreateInstance(CLSID_GroupPolicyObject,NULL,CLSCTX_INPROC_SERVER,IID_IGroupPolicyObject,(LPVOID*)&pGPO);
if(hr==S_OK)
{
cout<<"GPO创建成功\n";
}
else
{ cout<<"GPO创建失败\n";
return E_FAIL;
}
DWORD dwSection=GPO_SECTION_USER;
HKEY hGPOKey=0;
hr=pGPO->OpenLocalMachineGPO(GPO_OPEN_LOAD_REGISTRY);
if(SUCCEEDED(hr))
{
cout<<"打开本地机器成功\n";
}
else
{
cout<<"打开本地失败\n";
return E_FAIL;
}
hr=pGPO->GetRegistryKey(dwSection,&hGPOKey);
if(SUCCEEDED(hr))
{
cout<<"加载zc表成功\n";
}
else
{
cout<<"加载zc表失败\n";
return E_FAIL;
}
//禁用任务管理器
HKEY hKey=NULL; if(mark==1)
{
status=RegOpenKeyEx(hGPOKey,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0,KEY_WRITE,&hKey);
if(status!=ERROR_SUCCESS)
{
status=RegCreateKeyEx(hGPOKey,"Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System",0,NULL,REG_OPTION_NON_VOLATILE,KEY_WRITE,NULL,&hKey,NULL);
if(status==S_OK)
{
cout<<"创建键值成功\n";
}
else
{
cout<<"创建键值失败\n";
return E_FAIL;
}
}
DWORD lpData=1;
status=RegSetKeyValue(hKey,NULL,"DisableTaskMgr",REG_DWORD,(LPCVOID)&lpData,4);
status = RegCloseKey(hKey);
}
GUID Registerid=REGISTRY_EXTENSION_GUID;
GUID ThisGuid={
0x0F6B957E,
0x509E,
0x11D1,
{0xA7, 0xCC, 0x00, 0x00, 0xF8, 0x75, 0x71, 0xE3}
};
RegCloseKey(hGPOKey);
status=pGPO->Save(FALSE,TRUE,&Registerid,&ThisGuid);
pGPO->Release();
::CoUninitialize();
}
int main()
{
DisableTaskMgr(1);
}
原贴地址https://blog.csdn.net/dasgk/article/details/39347785?utm_source=blogxgwz1
补充内容 (2020-1-1 19:03):
这个只是个列子 实际并不是修改这个 单独直接zc表操作个别设置是可以 但是很多都不能直接zc表直接修改 路面的Object 值是变动的 而且 组策略也不会变动更新 |
|