Internet选项 添加信任站点
print?//ListBox里添加了两个信任站点m_ListBox.AddString("172.100.60.8");
m_ListBox.AddString("172.100.60.18");
//ListBox里添加了两个信任站点
m_ListBox.AddString("172.100.60.8");
m_ListBox.AddString("172.100.60.18");
[cpp]
BOOL CIEDlg::AddSite()
{
for(int i=0; i<m_ListBox.GetCount(); i++)
{
CString Site;
m_ListBox.GetText(i, Site);
for(int j=1; j<100; j++)
{
//添加新项
HKEY hKey;
DWORD lp_disp;
//打开注册表
CString index;
index.Format("%d",j);
CString m_path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + index;
LONG lnRes = ::RegCreateKeyEx(
HKEY_CURRENT_USER,
m_path, //子目录路径
0L,//必须取0
NULL,
REG_OPTION_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&lp_disp);
//如果打开已有的或者不成功,则continue;
if(lp_disp == REG_OPENED_EXISTING_KEY || lnRes != ERROR_SUCCESS) continue;
LPBYTE Data = new BYTE[4];
int _Data[4] = {2,0,0,0};
for(int i=0; i<4; i++)
{
*(Data+i) = _Data[i];
}
lnRes = RegSetValueEx(hKey,
"*",
0,
REG_DWORD,
Data,
REG_DWORD );
unsigned char site_Data[30];
lstrcpy( (char *) site_Data , LPCTSTR(Site) );
lnRes = RegSetValueEx(hKey,
":Range",
0,
REG_SZ,
site_Data,
Site.GetLength()+1 );
//若果成功添加一个网址,则break;
if( ERROR_SUCCESS == lnRes )
break;
else
AfxMessageBox("失败");
}
}
return true;
}
BOOL CIEDlg::AddSite()
{
for(int i=0; i<m_ListBox.GetCount(); i++)
{
CString Site;
m_ListBox.GetText(i, Site);
for(int j=1; j<100; j++)
{
//添加新项
HKEY hKey;
DWORD lp_disp;
//打开注册表
CString index;
index.Format("%d",j);
CString m_path = "SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Internet Settings\\ZoneMap\\Ranges\\Range" + index;
LONG lnRes = ::RegCreateKeyEx(
HKEY_CURRENT_USER,
m_path, //子目录路径
0L,//必须取0
NULL,
REG_OPTION_VOLATILE,
KEY_ALL_ACCESS,
NULL,
&hKey,
&lp_disp);
//如果打开已有的或者不成功,则continue;
if(lp_disp == REG_OPENED_EXISTING_KEY || lnRes != ERROR_SUCCESS) continue;
LPBYTE Data = new BYTE[4];
int _Data[4] = {2,0,0,0};
for(int i=0; i<4; i++)
{
*(Data+i) = _Data[i];
}
lnRes = RegSetValueEx(hKey,
"*",
0,
REG_DWORD,
Data,
REG_DWORD );
unsigned char site_Data[30];
lstrcpy( (char *) site_Data , LPCTSTR(Site) );
lnRes = RegSetValueEx(hKey,
":Range",
0,
REG_SZ,
site_Data,
Site.GetLength()+1 );
//若果成功添加一个网址,则break;
if( ERROR_SUCCESS == lnRes )
break; www.zzzyk.com
else
AfxMessageBox("失败");
}
}
return true;
}
补充:软件开发 , C++ ,