Newsgroup: it.comp.lang.visual-basic
Titolo: Internet: scarico di file htm... ma sempre quelli !!!

Ciao,
scarico e salvo in maniera hidden
su disco dei file htm che quotidianamente cambiano.
Uso questo VB6:
hOpen = InternetOpen("VB OpenUrl", _
                INTERNET_OPEN_TYPE_PRECONFIG, _
                vbNullString, vbNullString, 0)
hOpenUrl = InternetOpenUrl(hOpen, IndirizzoUrl, _
            vbNullString, 0, _
            INTERNET_FLAG_RELOAD, 0)
e soprattutto grazie al flag  INTERNET_FLAG_RELOAD
crederei di assicurarmi il fatto di pescare sempre quelli nuovi.
Ma invece pesca dalla cache (e lo fa velocemente ovviamente)
ma non sono i file freschi di giornata, ma sempre quelli ovviamente
del primo scarico di quell indirizzo url.
Se li cancello prima dalla cache a mano,
 invece va regolarmente a pescare quelli nuovi su Internet
(nota: sul mio browser IExplorer ho il setting 'non pescare mai dalla
cache', ma per il browswer, come detto, non ci passo per la veritą...)
Qualche idea ?
Bob

 Qualche idea ?
salvo le immagini di una webcam con
    b() = Inet1.OpenURL(strURL, icByteArray)
    Open fName  For Binary Access Write As #fNum
    Put #fNum, , b()
    Close #fNum
e dato che la cam cambia ogni 15" sono piu' che sicuro che ogni volta prende
quello nuovo.
in alternativa, per il webbrowser avevo trovato il codice qui sotto per
pulire la cache. ma non mi ha mai convinto del tutto, troppi "se e' andata
bene, continuiamo". oltre che se solo navighi un po' con ie, il tuo vb poi
sta li' parecchio.
ciao, a.
Option Explicit
Private Declare Function FindFirstUrlCacheGroup Lib "wininet.dll" ( _
    ByVal dwFlags As Long, _
    ByVal dwFilter As Long, _
    ByRef lpSearchCondition As Long, _
    ByVal dwSearchCondition As Long, _
    ByRef lpGroupId As Date, _
    ByRef lpReserved As Long) As Long
Private Declare Function FindNextUrlCacheGroup Lib "wininet.dll" ( _
    ByVal hFind As Long, _
    ByRef lpGroupId As Date, _
    ByRef lpReserved As Long) As Long
Private Declare Function DeleteUrlCacheGroup Lib "wininet.dll" ( _
    ByVal sGroupID As Date, _
    ByVal dwFlags As Long, _
    ByRef lpReserved As Long) As Long
Private Declare Function FindFirstUrlCacheEntry Lib "wininet.dll" Alias
"FindFirstUrlCacheEntryA" ( _
    ByVal lpszUrlSearchPattern As String, _
    ByRef lpFirstCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
    ByRef lpdwFirstCacheEntryInfoBufferSize As Long) As Long
Private Type INTERNET_CACHE_ENTRY_INFO
    dwStructSize As Long
    szRestOfData(1024) As Long
End Type
Private Declare Function DeleteUrlCacheEntry Lib "wininet.dll" Alias
"DeleteUrlCacheEntryA" ( _
    ByVal lpszUrlName As Long) As Long
Private Declare Function FindNextUrlCacheEntry Lib "wininet.dll" Alias
"FindNextUrlCacheEntryA" ( _
    ByVal hEnumHandle As Long, _
    ByRef lpNextCacheEntryInfo As INTERNET_CACHE_ENTRY_INFO, _
    ByRef lpdwNextCacheEntryInfoBufferSize As Long) As Long
Private Const CACHGROUP_SEARCH_ALL = &H0
Private Const ERROR_NO_MORE_FILES = 18
Private Const ERROR_NO_MORE_ITEMS = 259
Private Const CACHEGROUP_FLAG_FLUSHURL_ONDELETE = &H2
Private Const BUFFERSIZE = 2048
Public Sub ClearCache()
    Dim sGroupID As Date
    Dim hGroup As Long
    Dim hFile As Long
    Dim sEntryInfo As INTERNET_CACHE_ENTRY_INFO
    Dim iSize As Long
    On Error Resume Next
    ' Delete the groups
    hGroup = FindFirstUrlCacheGroup(0, 0, 0, 0, sGroupID, 0)
    ' To avoid error using it with IE4 as FindFirstUrlCacheGroup is not
implemented
    If Err.Number <> 453 Then
        If (hGroup = 0) And (Err.LastDllError <> 2) Then
            MsgBox "An error occurred enumerating the cache groups" &
Err.LastDllError
            Exit Sub
        End If
    Else
        Err.Clear
    End If
    If (hGroup <> 0) Then
        'we succeeded in finding the first cache group.. enumerate and
        'delete
        Do
            If (0 = DeleteUrlCacheGroup(sGroupID,
CACHEGROUP_FLAG_FLUSHURL_ONDELETE, 0)) Then
               ' To avoid error using it with IE4 as FindFirstUrlCacheGroup
is not implemented
               If Err.Number <> 453 Then
                 MsgBox "Error deleting cache group " & Err.LastDllError
                 Exit Sub
               Else
                  Err.Clear
               End If
            End If
            iSize = BUFFERSIZE
            If (0 = FindNextUrlCacheGroup(hGroup, sGroupID, iSize)) And
(Err.LastDllError <> 2) Then
                MsgBox "Error finding next url cache group! - " &
Err.LastDllError
            End If
        Loop Until Err.LastDllError = 2
    End If
  ' Delete the files
    sEntryInfo.dwStructSize = 80
    iSize = BUFFERSIZE
    hFile = FindFirstUrlCacheEntry(0, sEntryInfo, iSize)
    If (hFile = 0) Then
        If (Err.LastDllError = ERROR_NO_MORE_ITEMS) Then
            GoTo done
        End If
        MsgBox "ERROR: FindFirstUrlCacheEntry - " & Err.LastDllError
        Exit Sub
    End If
    Do
        If (0 = DeleteUrlCacheEntry(sEntryInfo.szRestOfData(0))) _
            And (Err.LastDllError <> 2) Then
            Err.Clear
        End If
        iSize = BUFFERSIZE
        If (0 = FindNextUrlCacheEntry(hFile, sEntryInfo, iSize)) And
(Err.LastDllError <> ERROR_NO_MORE_ITEMS) Then
'            MsgBox "Error:  Unable to find the next cache entry - " &
Err.LastDllError
'            Resume Next
            Exit Do
        End If
    Loop Until Err.LastDllError = ERROR_NO_MORE_ITEMS
done:
    MsgBox "cache cleared"
End Sub

 ha scritto nel messaggio 
news:42d6f759...@powernews.inwind.it...

Prova con INTERNET_FLAG_DONT_CACHE (&H4000000)
ciao. 


Prova questo per cancellare preventivamente dalla cache il file:
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
  Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long
Prima della scarico chiama questa:
Call DeleteUrlCacheEntry(IndirizzoUrl)
P.S: Non l'ho provato, ma penso che funzioni
Ciao, Paolo