代码禁用但无法启用 [英] Code Disables But Won't Enable

查看:118
本文介绍了代码禁用但无法启用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这段代码可以编辑Windows注册表.当设置设置为启用时,它工作正常,我运行以下代码以禁用...

I have this code that edits the windows registry. It works fine when the setting is set to enable and I run the following code to disable...

HKEY hKey; DWORD buffersize = 1024; DWORD dwErr = NO_ERROR; 
#define BUFFER_SIZE 1024
dwErr = RegOpenKeyEx (HKEY_CURRENT_USER,"Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\Zones\\3",NULL,KEY_SET_VALUE|KEY_QUERY_VALUE,&hKey);
	if(ERROR_SUCCESS == dwErr)
	{
	BYTE data[BUFFER_SIZE] = {0};
	DWORD dwType = REG_NONE;
	dwErr = RegQueryValueExW(hKey,L"1803",NULL,&dwType,data,&buffersize);
		if(ERROR_SUCCESS == dwErr && REG_DWORD == dwType)
                {
		*((LPDWORD)data) = 3; //0 is Enable 3 is Disable
		dwErr = RegSetValueExW(hKey,L"1803",0,REG_DWORD,data,sizeof(DWORD));
		}
		RegCloseKey (hKey);
		}


但是,当我尝试切换此行时*((LPWORD)data)= 0;
它不会从禁用更改为启用.也许我必须清除缓冲区?任何建议欢迎.谢谢.


However when I try to switch this line *((LPWORD)data) = 0;
It doesn''t change from disabled to enabled. Perhaps I have to clear the BUFFER? Any suggestions welcomed. Thank you.

推荐答案

代码有效.如果使用regedit查看更改,则需要从菜单中选择View-> Refresh()才能查看更改.

快速说明...此注册表项更改了区域3(Internet区域)中基于Microsoft Trident的浏览器的Internet安全设置.您很可能需要向HWND_BROADCAST句柄发送WM_SETTINGCHANGE消息,以通知应用程序设置已更改.

最好的祝福,
-大卫·德劳恩(David Delaune)
The code works. If you are using regedit to view the changes then you need to select View->Refresh() from the menu to see the changes.

A quick note... this registry key changes an internet security setting for Microsoft Trident based browsers at zone 3 (Internet Zone). You will most likely need to send a WM_SETTINGCHANGE message to the HWND_BROADCAST handle to notify applications that a setting has been changed.

Best Wishes,
-David Delaune


这篇关于代码禁用但无法启用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆