VB用inet控件怎样才能不读取缓存连接网络上的文件?
|
admin
2014年2月24日 17:33
本文热度 7047
|
我用inet控件建立了一个连接,连接过一次之后就会产生了缓存,下次再连接时它会先读取缓存的内容,这样得到的内容就是旧的了,而我想要的是不管有无连接过,都是连接到远程读取远程的相关内容,这要怎么实现?
该文章在 2014/2/24 17:33:30 编辑过
| |
全部评论1 |
|
admin
2014年2月24日 17:34
方法1.
对URL进行更改,让它每次访问不同的URL但指向相同的页面。
可在URL结尾添加一些无意义的参数:http://www.86lg.com/?abc=1
你可以用rnd生成随机数实现,简单。
方法2.
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 |
Public Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Public Declare Function DeleteUrlCacheEntry Lib "wininet" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Public Function DownloadFile(Url As String, LocalFilename As String) As Boolean
Dim lngRetVal As Long
lngRetVal = URLDownloadToFile(0, Url, LocalFilename, 0, 0)
If lngRetVal = 0 Then
DownloadFile = True
DeleteUrlCacheEntry Url
End If
End Function
使用方法:
DownloadFile "http://www.baidu.com/img/lm.gif", App.Path & "\lm.gif"
| 该评论在 2014/2/24 17:34:16 编辑过
|