您的位置:首页 > 其它

修改注册表,实现屏蔽IE右键功能

2005-01-20 01:25 567 查看
屏蔽IE右键的方法:只需将这册表中:Software\\Policies\\Microsoft\\Internet Explorer\\Restrictions项中的NoBrowserContextMenu设置为1

HKEY  hk;   

    if  (RegCreateKey(HKEY_CURRENT_USER,  "Software\\Policies\\Microsoft\\Internet Explorer",  &hk))   

           ::MessageBox(NULL,  "Could  not  create  the  registry  key.",  "",  MB_OK);   

 

    if  (RegCreateKey(HKEY_CURRENT_USER,  "Software\\Policies\\Microsoft\\Internet Explorer\\Restrictions",  &hk))   

           ::MessageBox(NULL,  "Could  not  create  the  registry  key.",  "",  MB_OK);   

    RegCloseKey(hk); 

 RootKey=HKEY_CURRENT_USER;     //注册表主键名称

 SubKey="Software\\Policies\\Microsoft\\Internet Explorer\\Restrictions";  //欲打开注册表值的地址

 ValueName="NoBrowserContextMenu";               //欲设置值的名称

 SetContent_D[0]=1;             //值的内容

 if((SetValue_D(RootKey,SubKey,ValueName,SetContent_D))!=0)

  AfxMessageBox("操作失败!");

其中int SetValue_D (struct HKEY__*ReRootKey,TCHAR *ReSubKey,TCHAR *ReValueName,int ReSetContent_D[256])是设置DWORD值函数:

SetValue_D (struct HKEY__*ReRootKey,TCHAR *ReSubKey,TCHAR *ReValueName,int ReSetContent_D[256])

{

 int i=0; //操作结果:0==succeed

 if(RegOpenKeyEx(ReRootKey,ReSubKey,0,KEY_WRITE,&hKey)==ERROR_SUCCESS)

 {

  if(RegSetValueEx(hKey,ReValueName,NULL,REG_DWORD,(const unsigned char *)ReSetContent_D,4)!=ERROR_SUCCESS)

  {

   AfxMessageBox("错误:无法设置有关的注册表信息");

   i=1;

  }

  RegCloseKey(hKey);

 }

 else

 {

  AfxMessageBox("错误:无法查询有关的注册表信息");

  i=1;

 }

 return i;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: