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.2cto.com else AfxMessageBox("失敗"); } } return true; }