As the number of Internet times is increasing, there is a lot of historical website in the IE address bar, which is very uncomfortable, so determined to write an application that clears the IE address bar, then there is "Internet Assistant", but it is available to access the Internet When I play, I want to clean the system when I can't get online, so I wrote a program called the IEurlender --- IE address terminator. First introduce the principle of clearing the IE address bar. Everyone knows that all of our operations on the machine, there are records in the registry. IE is no exception. When entering the URL in the IE address bar, it is recorded in the registry. Specifically, under HKEY_CURRENT_USER / SOFTWARE / Microsoft / Internet Explorer / TypedURLs. If you delete all key values under TypedURLs, you can clear the role of the history record of the IE address bar, but the manual modification registry is more troublesome. Especially when the number of records is large, the direct opening of the registry is not a pleasant job. Of course, this is not a way. The above introduction is the working principle of the program. Next, introduce the things on the interface. My idea is to list all IE address bar history records on the interface for selective deletion. However, Visual C 6.0 is not available in Visual Studio .NET to provide CChecklistbox such a ListBox for programmers. However, Visual C 6.0 provides programmers with an extensible Cchecklistbox class, and the CCheckListbox class is inherited from CListBox, so the former has the latter properties and methods, and CCHCEKLISTBOX has its own unique way, such as getcheck (int CHECK INDEX) and SETCHECK (INT INDEX, BOOL CHECK). This allows users to make Listbox with Checkbox in the interface. I am doing this. How to implement it? 1) Create a Dialogue-based application. 2) Put a list box on the form, and the ID is set to ID_LIST. 3) Adding variables to the program via ClassWizard, when adding variables to the List box, the variable type is selected as the CListBox Control type, and the variable is named m_list. 4) Find the definition of M_List in this form: // Dialog Data // {{AFX_DATA (CIEURLENDERDLG) Enum {IDD = IDD_IEURLENDER_DIALOG}; // clistbox m_list; // Change it here Cchecklistbox M_List; cbutton m_selectall; cbutton m_deleselected; cbutton m_cancelt; //}} AFX_DATA
This will appear on the interface to appear Listbox with checkbox. (Because you can't map here, you can't figure it up. The recommended version of the master can map all people who publish the article so that the reader can have an intuitive feeling, huh, huh) the program is to initialize ListBox by OnInitDialog (). Bool cieurlenderdlg :: OnIndialog () {cdialog :: oninitdialog (); // add "about ..." Menu Item to System Menu.
// IDM_ABOUTBOX MUST BE IN THE SYSTEM Command Range. Assert ((idm_aboutbox & 0xff0) == idm_aboutbox; assert (idm_aboutbox <0xf000);
CMenu * pSysMenu = GetSystemMenu (FALSE); if (pSysMenu = NULL!) {CString strAboutMenu; strAboutMenu.LoadString (IDS_ABOUTBOX); if {pSysMenu-> AppendMenu (MF_SEPARATOR) (strAboutMenu.IsEmpty ()!); PSysMenu-> AppendMenu ( MF_String, IDM_AboutBox, Straboutmenu);}}
// set the icon for this dialog. The framework does this automatic or //en the application's main window is not a dialog seticon (m_hicon, true); // set big icon seticon (m_hicon, false); // set small icon / / TODO: ADD Extra Initialization Here / ************************************ /// HKEY HKEY = NULL;
HKEY HROOTKEY = HKEY_CURRENT_USER; LPCTSTST SUBKEY = "Software // Microsoft // Internet Explorer // TypedURLS"
Bool m_berror = regopenkeyex (Hrootkey, Subkey, 0, Key_all_access, & hkey); if (m_berror! = Error_success) {regcloseKey (HKEY); MessageBox ("Open Key Error"); exit (0);}
// cstring m_skey = ""; cstring m_surl = ""
DWORD DWTYPE = REG_SZ; DWORD DWSIZE = 255;
// _ tchar char * sz = null; bool m_bqueryerror = false;
For (int i = 1; i <20; i ) // This assumes up to 19 records, readers can write better programs to enumerate all records {m_surl = ""; sz = (char *) malloc (255 * sizeof (char)); dwsize = 255;
M_skey.format ("URL% D", I); // Read URL M_Berror = RegQueryValueex (HKEY, LPCTSTSTSTSTSTS, NULL, & DWTYPE, (LPBYTE) SZ, & DWSIZE); if (M_Berror! = Error_Success) {RegCloseKey (hkey); m_bqueryerror = true; break;} m_surl = (cstring) sz;
IF (! m_surl.isempty ()) m_list.insertstring (i-1, m_surl); // Insert Free (SZ) in cchecklistbox;} if (! m_bqueryerror) // MessageBox ("Query Error"); // Else RegcloseKey (HKEY); ///
Return True; // Return True UnsS you set the focus to a control} In addition, I added 4 Button on the interface, which is "select all records", "cancel the selection", "delete the selected item", "exit ". The response code of "Select all records" is as follows: void cieurlenderdlg :: OnsenderLender () {// Todo: add your control notification handler code here int m_iumnum = m_list.getcount (); // Get record number of records in cchecklistbox (int I = 0; I Void cieurlenderdlg :: oncanceLall () {// Todo: add your control notification handler code here int m_iumnum = m_list.getcount (); for (int i = 0; i Void cieurlenderdlg :: overdeeleselected () {// Todo: add your control notification handler code here hkey hkey = null; HKEY HROOTKEY = HKEY_CURRENT_USER; LPCTSTST SUBKEY = "Software // Microsoft // Internet Explorer // TypedURLS" // First open the registry response key bool m_berror = regopenkeyex (hrootkey, subkey, 0, key_all_access, & hkey); if (m_berror! = Error_success) {regcloseKey (HKEY); MessageBox ("Open key error"); EXIT (0) } // // Remove int m_iumnum = m_list.getcount (); for (int i = m_iarchnum; i> = 0; I -) // Note: The loop variable is from big to small, because you delete a button In CCheklistbox, the index of its later item will be automatically reduced, and it will be wrong when it is judged by getCheck (i). { IF (m_list.getcheck (i-1) == true) {// m_list.deleteString (i); // cstring m_surl = ""; m_surl.format ("URL% D", i); // From the registry Remove the key regdeletevalue (hkey, m_surl);}} RegcloseKey (HKEY);} Ok, the main places of the program are finished, I hope to have some help for some friends. ====================================== I also want to do it better, then make a plugin Like the 3721 Internet access assistant, becomes a TOOLBAR of IE, and I hope the masters will give pointers. Requires a friend of the source code tells me your e-mail. My E-mail: banrenma23@yahoo.com.cnmsn: Honwei_liu @ Hotmail.com