• <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>
    • 軟件測試技術
    • 軟件測試博客
    • 軟件測試視頻
    • 開源軟件測試技術
    • 軟件測試論壇
    • 軟件測試沙龍
    • 軟件測試資料下載
    • 軟件測試雜志
    • 軟件測試人才招聘
      暫時沒有公告

    字號: | 推薦給好友 上一篇 | 下一篇

    判斷一個文件是否在IE的緩存中

    發布: 2007-7-14 20:28 | 作者: 佚名    | 來源: 網絡轉載     | 查看: 17次 | 進入軟件測試論壇討論

    領測軟件測試網 當你建立一個聯到網上文件的快捷方式時,你可能需要知道它是否已經被訪問過,于是你就可以適當地改變鏈接的顏色等等。這則小技巧

    就是告訴你如何判斷一個文件是否在inte.net explorer的緩存中,以滿足你的須要。

      新建一個項目、添加一個模塊。將以下代碼寫到模塊里:


    private const error_insufficient_buffer = 122

    private const eeerrorbase = 26720


    private type filetime

      dwlowdatetime as long

      dwhighdatetime as long

    end type


    private type internet_cache_entry_info

      dwstructsize as long

      lpszsourceurlname as string

      lpszlocalfilename as string

      cacheentrytype as string

      dwusecount as long

      dwhitrate as long

      dwsizelow as long

      dwsizehigh as long

      lastmodifiedtime as filetime

      expiretime as filetime

      lastaccesstime as filetime

      lastsynctime as filetime

      lpheaderinfo as long

      dwheaderinfosize as long

      lpszfileextension as string

      dwreserved as long

    end type


    private declare function geturlcacheentryinfo lib "wininet.dll" _

    alias "geturlcacheentryinfoa" (byval surlname as string, _

      lpcacheentryinfo as any, lpdwcacheentryinfobuffersize _

      as long) as long


    ’用來報告api產生的錯誤:

    private const format_message_allocate_buffer = &h100

    private const format_message_argument_array = &h2000

    private const format_message_from_hmodule = &h800

    private const format_message_from_string = &h400

    private const format_message_from_system = &h1000

    private const format_message_ignore_inserts = &h200

    private const format_message_max_width_mask = &hff

    private declare function formatmessage lib "kernel32" alias _

      "formatmessagea" (byval dwflags as long, lpsource as any, _

      byval dwmessageid as long, byval dwlanguageid as long, _

      byval lpbuffer as string, byval nsize as long, arguments _

      as long) as long


    public function winapierror(byval llastdllerror as long) as string

    dim sbuff as string

    dim lcount as long


      ’返回與lastdllerror相關的出錯信息:

      sbuff = string$(256, 0)

      lcount = formatmessage( _

       format_message_from_system or format_message_ignore_inserts, _

       0, llastdllerror, 0&, sbuff, len(sbuff), byval 0)

      if lcount then

       winapierror = left$(sbuff, lcount)

      end if


    end function


    public function getcacheentryinfo(byval hwnd as long, _

      byval lpszurl as string) as boolean


    dim dwentrysize as long

    dim lpcacheentry as internet_cache_entry_info

    dim dwtemp as long

    dim lerr as long


      if (geturlcacheentryinfo(lpszurl, byval 0&, dwentrysize)) = 0 then

       lerr = err.lastdllerror

       if (lerr <> error_insufficient_buffer) then

         ’預料外的錯誤。須要顯示出錯原因:

         err.raise eeerrorbase + 1, _

          app.exename & ".mcacheentry", winapierror(lerr)


         getcacheentryinfo = false

         exit function

       else

         ’這是預料中的錯誤

         getcacheentryinfo = true

       end if

      end if


    end function



    在窗體上添加一個command和一個text。然后加入這些代碼:


    option explicit


    private sub command1_click()

    on error goto errorhandler

      ’檢查text中的url地址是否出現在緩存中:

      if (getcacheentryinfo(me.hwnd, text1.text)) then

       msgbox "url in cache.", vbinformation

      else

       msgbox "url not in cache.", vbinformation

      end if


    exit sub


    errorhandler:

     msgbox "url not in cache [" & err.description & "]",vbinformation


    end sub


      運行,在text中鍵入一個url地址(比如,http://www.vbaccelerator.com/index.html)當你按下command按鈕時,就會得到一則消息報告url在不在緩存中。如果windows給出了url沒找到的原因,它將被顯示在隨后的的方括號內。

    文章來源于領測軟件測試網 http://www.kjueaiud.com/


    關于領測軟件測試網 | 領測軟件測試網合作伙伴 | 廣告服務 | 投稿指南 | 聯系我們 | 網站地圖 | 友情鏈接
    版權所有(C) 2003-2010 TestAge(領測軟件測試網)|領測國際科技(北京)有限公司|軟件測試工程師培訓網 All Rights Reserved
    北京市海淀區中關村南大街9號北京理工科技大廈1402室 京ICP備10010545號-5
    技術支持和業務聯系:info@testage.com.cn 電話:010-51297073

    軟件測試 | 領測國際ISTQBISTQB官網TMMiTMMi認證國際軟件測試工程師認證領測軟件測試網

    老湿亚洲永久精品ww47香蕉图片_日韩欧美中文字幕北美法律_国产AV永久无码天堂影院_久久婷婷综合色丁香五月

  • <ruby id="5koa6"></ruby>
    <ruby id="5koa6"><option id="5koa6"><thead id="5koa6"></thead></option></ruby>

    <progress id="5koa6"></progress>

  • <strong id="5koa6"></strong>