private void Query_Click(object sender, System.EventArgs e) { STATURL s = urlHistory.QueryUrl(textBoxQueriedURL.Text, STATURL_QUERYFLAGS.STATURL_QUERYFLAG_TOPLEVEL); if(s.pwcsUrl != null) textBoxResult.Text = "\"" + textBoxQueriedURL.Text + "\" has been visited by the current user."; else textBoxResult.Text = "\"" + textBoxQueriedURL.Text + "\" has not been visited by the current user."; }
/// <summary> /// Advances the enumerator to the next item of the url history cache. /// </summary> /// <returns> /// true if the enumerator was successfully advanced to the next element; /// false if the enumerator has passed the end of the url history cache. /// </returns> public bool MoveNext() { _staturl = new STATURL(); _enumerator.Next(1, ref _staturl, out _index); if (_index == 0) { return(false); } return(true); }
/// <summary> /// Enumerate the items in the history cache and store them in the IList object. /// </summary> /// <param name="list"> /// IList object /// <example><c>ArrayList</c>object</example> /// </param> public void GetUrlHistory(IList list) { while (true) { _staturl = new STATURL(); _enumerator.Next(1, ref _staturl, out _index); if (_index == 0) { break; } //if (_staturl.URL.StartsWith("http")) list.Add(_staturl); } _enumerator.Reset(); }
/// <summary> /// Gets all stored history items. /// </summary> /// <returns>The history items</returns> private List <string> GetHistoryItems() { var urlHistory = new CUrlHistory(); var urlHistoryStg = (IUrlHistoryStg)urlHistory; var history = new List <string>(); var enumrator = (IEnumSTATURL)urlHistoryStg.EnumUrls; while (true) { var staturl = new STATURL(); int index; enumrator.Next(1, ref staturl, out index); if (index == 0) { break; } var url = staturl.pwcsUrl; var qi = staturl.pwcsUrl.IndexOf('?'); if (qi != -1) { url = url.Substring(0, qi); } history.Add((url + '\0').ToLower()); } var typedUrls = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Internet Explorer\TypedURLs"); if (typedUrls != null) { foreach (var name in typedUrls.GetValueNames()) { var url = typedUrls.GetValue(name, string.Empty) as string; if (url != null) { history.Add((url + '\0').ToLower()); } } } return(history); }
/// <summary> /// Queries the history and reports whether the URL passed as the pocsUrl parameter has been visited by the current /// user. /// </summary> /// <param name="pocsUrl">the string of the URL to querythe string of the URL to query.</param> /// <param name="dwFlags"> /// STATURL_QUERYFLAGS Enumeration /// <example> /// <c>STATURL_QUERYFLAGS.STATURL_QUERYFLAG_TOPLEVEL</c> /// </example> /// </param> /// <returns> /// Returns STATURL structure that received additional URL history information. If the returned STATURL's pwcsUrl is /// not null, Queried URL has been visited by the current user. /// </returns> public STATURL QueryUrl(string pocsUrl, STATURL_QUERYFLAGS dwFlags) { var lpStaturl = new STATURL(); try { //In this case, queried URL has been visited by the current user. _obj.QueryUrl(pocsUrl, dwFlags, ref lpStaturl); //lpSTATURL.pwcsUrl is NOT null; return(lpStaturl); } catch (FileNotFoundException) { //Queried URL has not been visited by the current user. //lpSTATURL.pwcsUrl is set to null; return(lpStaturl); } }