Print? // Two Trust sites m_ListBox.AddString ("Hangzhou"); m_ListBox.AddString ("172.100.60.18") are added to ListBox; // two Trust sites m_ListBox.AddString ("172.100.60.8") are added to ListBox "); 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 ++) {// Add a new HKEY hKey; DWORD lp_disp; // open the Registry 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, // subdirectory path 0L, // 0 NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, & hKey, & lp_disp ); // if an existing or failed operation is enabled, continue; if (lp_disp = REG_OPENED_EXISTING_KEY | lnRes! = ERROR_SUCCESS) continue; LPBYTE Data = new BYTE [4]; int _ Data [4] = {2, 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); // if a URL is successfully added, break; if (ERROR_SUCCESS = lnRes) Break; else AfxMessageBox ("failed") ;}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 ++) {// Add a new HKEY hKey; DWORD lp_disp; // open the Registry CString index; index. format ("% d", j ); CString m_path = "SOFTWARE \ Microsoft \ Windows \ CurrentVersion \ Internet Settings \ ZoneMap \ Ranges \ Range" + index; LONG lnRes =: RegCreateKey Ex (HKEY_CURRENT_USER, m_path, // subdirectory path 0L, // 0 NULL, REG_OPTION_VOLATILE, KEY_ALL_ACCESS, NULL, & hKey, & lp_disp ); // if an existing or failed operation is enabled, continue; if (lp_disp = REG_OPENED_EXISTING_KEY | lnRes! = ERROR_SUCCESS) continue; LPBYTE Data = new BYTE [4]; int _ Data [4] = {2, 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); // if a URL is successfully added, break; if (ERROR_SUCCESS = lnRes) break; www.2cto. comelseAfxMessageBox ("failed") ;}} return true ;}