您的位置:程序门 -> .net技术 -> c#



如何取得浏览器的历史记录,读取为字符窜形式


[收藏此页] [打印本页]选择字色:背景色:字体:[][][]


如何取得浏览器的历史记录,读取为字符窜形式[已结贴,结贴人:huing]
发表于:2007-03-08 16:02:03 楼主
就是读取到以后如何列出来(读取文件夹以后出现的是什么昨天、今天之类的),   如何列出所有浏览过的地址,就像ie   history   manager(http://www.cleanersoft.com/iehistory/iehistory.htm)作的那样
发表于:2007-03-08 16:10:461楼 得分:10
using   system.runtime.interopservices;

[structlayout(layoutkind.sequential)]
public   class   internet_cache_entry_infow
{
        public   uint   dwstructsize;
        public   string   lpszsourceurlname;
        public   string   lpszlocalfilename;
        public   uint   cacheentrytype;
        public   uint   dwusecount;
        public   uint   dwhitrate;
        public   uint   dwsizelow;
        public   uint   dwsizehigh;
        public   filetime   lastmodifiedtime;
        public   filetime   expiretime;
        public   filetime   lastaccesstime;
        public   filetime   lastsynctime;
        public   intptr   lpheaderinfo;
        public   uint   dwheaderinfosize;
        public   string   lpszfileextension;
        public   uint   dwreserved;   //union   uint   dwexemptdelta;
}

[dllimport( "wininet.dll ")]
public   static   extern   intptr   findfirsturlcacheentryex(

    string   lpszurlsearchpattern,
    uint   dwflags,
    uint   dwfilter,
    int64   groupid,
    intptr   lpfirstcacheentryinfo,
    ref   uint   lpdwfirstcacheentryinfobuffersize,
    pointer   lpgroupattributes,
    pointer   pcbgroupattributes,
    pointer   lpreserved
);

[dllimport( "wininet.dll ")]
public   static   extern   bool   findcloseurlcache(intptr   henumhandle);

[dllimport( "wininet.dll ")]
public   static   extern   bool   findnexturlcacheentryex(
        intptr   henumhandle,
        intptr   lpfirstcacheentryinfo,
        ref   uint   lpdwfirstcacheentryinfobuffersize,
        pointer   lpgroupattributes,
        pointer   pcbgroupattributes,
        pointer   lpreserved);

public   uint   normal_cache_entry   =   0x00000001;

private   void   button4_click(object   sender,   eventargs   e)
{
        intptr   vhandle;
        internet_cache_entry_infow   vinternetcacheentryinfo   =   new   internet_cache_entry_infow();
        uint   vfirstcacheentryinfobuffersize   =   0;
        findfirsturlcacheentryex(null,   0,   normal_cache_entry,   0,   (intptr)null,
                ref   vfirstcacheentryinfobuffersize,   null,   null,   null);
        intptr   vbuffer   =   marshal.allochglobal((int)vfirstcacheentryinfobuffersize);
        vhandle   =   findfirsturlcacheentryex(null,   0,   normal_cache_entry,   0,
              vbuffer,   ref   vfirstcacheentryinfobuffersize,
              null,   null,   null);
        while   (vhandle   !=   null)
        {
                marshal.ptrtostructure(vbuffer,   vinternetcacheentryinfo);
                richtextbox1.appendtext(vinternetcacheentryinfo.lpszsourceurlname   +   "\r\n ");
                marshal.freecotaskmem(vbuffer);

                findnexturlcacheentryex(vhandle,   (intptr)null,   ref   vfirstcacheentryinfobuffersize,
                    null,   null,   null);
                vbuffer   =   marshal.allochglobal((int)vfirstcacheentryinfobuffersize);
                if   (!findnexturlcacheentryex(vhandle,   vbuffer,
                      ref   vfirstcacheentryinfobuffersize,   null,   null,   null))   break;
        }
        marshal.freecotaskmem(vbuffer);
}
发表于:2007-03-09 09:18:382楼 得分:0
pointer是指指针?
需要设置使用不安全代码?
还是需要引用某一个dll

我这里编译不过阿
发表于:2007-03-09 10:57:423楼 得分:0
system.reflection.pointer
我的调试环境是2005
pointer声明在system.reflection命名空间

你可以这样调试
pointer   ->   intptr
null   ->   intptr.zero
发表于:2007-03-09 12:07:324楼 得分:0
2005中不用这么麻烦
发表于:2007-03-09 12:09:095楼 得分:0
设置combobox的autocompletesource属性就行
发表于:2007-03-09 12:21:296楼 得分:0
不需要这么复杂,有一个com可以实现这种功能
发表于:2007-03-09 12:25:537楼 得分:0
hongyelzg(风中过客)   (   )   信誉:100         blog     2007-03-09   12:21:29     得分:   0    
 
 
      不需要这么复杂,有一个com可以实现这种功能
   
 
哪一个??请指点一下,谢谢
发表于:2007-03-09 16:34:488楼 得分:0
up
发表于:2007-03-10 22:38:239楼 得分:0
textbox1.autocompletesource   =   autocompletesource.historylist
发表于:2007-03-12 09:00:3510楼 得分:0
autocompletesource好像是2005特有的,   2003怎么获取呢?
发表于:2007-03-12 11:33:5811楼 得分:10
http://www.xfbbs.com/articleshow/84/article_show_24841.html
http://www.ccwblog.cn/ylsun/post/20061120/13258.htm


.net   2.0中的autocomplete正是通过此方法实现的,2.0中实现的原型

private   void   setautocomplete(bool   reset,   bool   recreate)
{
        if   (base.ishandlecreated   &&   (this.childedit   !=   null))
        {
                if   (this.autocompletemode   !=   autocompletemode.none)
                {
                        if   ((!this.fromhandlecreate   &&   recreate)   &&   base.ishandlecreated)
                        {
                                autocompletemode   autocompletemode   =   this.autocompletemode;
                                this.autocompletemode   =   autocompletemode.none;
                                base.recreatehandle();
                                this.autocompletemode   =   autocompletemode;
                        }
                        if   (this.autocompletesource   ==   autocompletesource.customsource)
                        {
                                if   (this.autocompletecustomsource   !=   null)
                                {
                                        if   (this.autocompletecustomsource.count   ==   0)
                                        {
                                                int   flags   =   -1610612736;
                                                safenativemethods.shautocomplete(new   handleref(this,   this.childedit.handle),   flags);
                                        }
                                        else   if   (this.stringsource   !=   null)
                                        {
                                                this.stringsource.refreshlist(this.getstringsforautocomplete(this.autocompletecustomsource));
                                        }
                                        else
                                        {
                                                this.stringsource   =   new   stringsource(this.getstringsforautocomplete(this.autocompletecustomsource));
                                                if   (!this.stringsource.bind(new   handleref(this,   this.childedit.handle),   (int)   this.autocompletemode))
                                                {
                                                        throw   new   argumentexception(sr.getstring( "autocompletefailure "));
                                                }
                                        }
                                }
                        }
                        else   if   (this.autocompletesource   ==   autocompletesource.listitems)
                        {
                                if   (this.dropdownstyle   ==   comboboxstyle.dropdownlist)
                                {
                                        int   flags   =   -1610612736;
                                        safenativemethods.shautocomplete(new   handleref(this,   this.childedit.handle),   flags);
                                }
                                else   if   (this.itemscollection   !=   null)
                                {
                                        if   (this.itemscollection.count   ==   0)
                                        {
                                                int   flags   =   -1610612736;
                                                safenativemethods.shautocomplete(new   handleref(this,   this.childedit.handle),   flags);
                                        }
                                        else   if   (this.stringsource   !=   null)
                                        {
                                                this.stringsource.refreshlist(this.getstringsforautocomplete(this.items));
                                        }
                                        else
                                        {
                                                this.stringsource   =   new   stringsource(this.getstringsforautocomplete(this.items));
                                                if   (!this.stringsource.bind(new   handleref(this,   this.childedit.handle),   (int)   this.autocompletemode))
                                                {
                                                        throw   new   argumentexception(sr.getstring( "autocompletefailurelistitems "));
                                                }
                                        }
                                }
                        }
                        else
                        {
                                try
                                {
                                        int   num4   =   0;
                                        if   (this.autocompletemode   ==   autocompletemode.suggest)
                                        {
                                                num4   ¦=   -1879048192;
                                        }
                                        if   (this.autocompletemode   ==   autocompletemode.append)
                                        {
                                                num4   ¦=   0x60000000;
                                        }
                                        if   (this.autocompletemode   ==   autocompletemode.suggestappend)
                                        {
                                                num4   ¦=   0x10000000;
                                                num4   ¦=   0x40000000;
                                        }
                                        safenativemethods.shautocomplete(new   handleref(this,   this.childedit.handle),   ((int)   this.autocompletesource)   ¦   num4);
                                }
                                catch   (securityexception)
                                {
                                }
                        }
                }
                else   if   (reset)
                {
                        int   flags   =   -1610612736;
                        safenativemethods.shautocomplete(new   handleref(this,   this.childedit.handle),   flags);
                }
        }
}

 
发表于:2007-03-12 15:06:1712楼 得分:0
autocompletemode   不是还是2.0的?
楼上的这个方法还是说明2005的吧
发表于:2007-03-12 16:22:3713楼 得分:0
up
发表于:2007-03-12 16:28:2814楼 得分:0
希望下班前解决
发表于:2007-03-13 09:14:3815楼 得分:0
我提供的方法是2005的内部实现,原本就有的api方法,   dotnet出现之前就有了的
发表于:2007-03-13 09:15:3016楼 得分:0
既然2005用这个api实现,说明这应该是最合适的实现方法了
发表于:2007-03-13 10:24:2517楼 得分:0
这个方法还是有些问题的,而且得到的结果不仅仅是历史,还包括一些cache里的东西。
具体的我已经找到了
http://www.codeproject.com/csharp/ponta.asp?df=100&forumid=67589&exp=0&select=897325
这个是取到所有历史纪录的。


快速检索

最新资讯
热门点击