Newsgroup: it.comp.lang.visual-basic
Titolo: "Kill" non trova i file di sistema

Vorrei che un applicativo mi cancellasse i cookies dalla cartella "temporary
internet files", ma mi da errore rt "file non found", ma il file c'č.
Probabilmente č dovuto al fatto che tali file sono considerati di sistema
(se metto nella cartella un file mio allora lo trova e lo cancella).
Qualcuno ha mai affrontato la questione???
Grazie.

Il 15/12/2003 17.37, Domenico Bellavia scrisse:

Prova a vedere cosa si puo' fare con setattr.
ciao
	maxx
-- 
NOSPAM: Rimuovere i trattini dallo username!
Cut hyphens from my username!

 ha scritto nel messaggio
news:brkp4v$4e035$1...@ID-97197.news.uni-berlin.de...


 Qualcuno ha mai affrontato la questione???
Eh, sě, piů di uno. Per info, cerca su
http://www.google.com/advanced_group_search?hl=it
Bye, G.

Ciao Domenico
Ecco come quello che serve. In questo caso cancello solo i file temporanei
risparmiando i 'biscotti' , ma se vuoi cancellare
anche quelli basta commentare una riga
Saluti
Paolo B.
Public Const ERROR_CACHE_FIND_FAIL As Long = 0
Public Const ERROR_CACHE_FIND_SUCCESS As Long = 1
Public Const ERROR_FILE_NOT_FOUND As Long = 2
Public Const ERROR_ACCESS_DENIED As Long = 5
Public Const ERROR_INSUFFICIENT_BUFFER As Long = 122
Public Const MAX_PATH As Long = 260
Public Const MAX_CACHE_ENTRY_INFO_SIZE As Long = 4096
Public Const LMEM_FIXED As Long = &H0
Public Const LMEM_ZEROINIT As Long = &H40
Public Const lPtr As Long = (LMEM_FIXED Or LMEM_ZEROINIT)
Public Const NORMAL_CACHE_ENTRY As Long = &H1
Public Const EDITED_CACHE_ENTRY As Long = &H8
Public Const TRACK_OFFLINE_CACHE_ENTRY As Long = &H10
Public Const TRACK_ONLINE_CACHE_ENTRY As Long = &H20
Public Const STICKY_CACHE_ENTRY As Long = &H40
Public Const SPARSE_CACHE_ENTRY As Long = &H10000
Public Const COOKIE_CACHE_ENTRY As Long = &H100000
Public Const URLHISTORY_CACHE_ENTRY As Long = &H200000
Public Const URLCACHE_FIND_DEFAULT_FILTER As Long = NORMAL_CACHE_ENTRY Or _
                                                    COOKIE_CACHE_ENTRY Or _
                                                    URLHISTORY_CACHE_ENTRY
Or _
TRACK_OFFLINE_CACHE_ENTRY Or _
                                                    TRACK_ONLINE_CACHE_ENTRY
Or _
                                                    STICKY_CACHE_ENTRY
Public Type FILETIME
   dwLowDateTime As Long
   dwHighDateTime As Long
End Type
Public Type INTERNET_CACHE_ENTRY_INFO
   dwStructSize As Long
   lpszSourceUrlName As Long
   lpszLocalFileName As Long
   CacheEntryType  As Long
   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 Long
   dwExemptDelta  As Long
End Type
Public Declare Function FindFirstUrlCacheEntry Lib "wininet" _
   Alias "FindFirstUrlCacheEntryA" _
  (ByVal lpszUrlSearchPattern As String, _
   lpFirstCacheEntryInfo As Any, _
   lpdwFirstCacheEntryInfoBufferSize As Long) As Long
Public Declare Function FindNextUrlCacheEntry Lib "wininet" _
   Alias "FindNextUrlCacheEntryA" _
  (ByVal hEnumHandle As Long, _
   lpNextCacheEntryInfo As Any, _
   lpdwNextCacheEntryInfoBufferSize As Long) As Long
Public Declare Function FindCloseUrlCache Lib "wininet" _
   (ByVal hEnumHandle As Long) As Long
'Public Declare Function DeleteUrlCacheEntry Lib "wininet" _
'   Alias "DeleteUrlCacheEntryA" _
'  (ByVal lpszUrlName As String) As Long
' -- Comatibile win 98 / ME / 2000 / XP
Public Declare Function DeleteUrlCacheEntry Lib "wininet" _
  (ByVal lpszUrlName As String) As Long
Public Declare Sub CopyMemory Lib "KERNEL32" _
   Alias "RtlMoveMemory" _
   (pDest As Any, _
    pSource As Any, _
    ByVal dwLength As Long)
Public Declare Function lstrcpyA Lib "KERNEL32" _
  (ByVal RetVal As String, ByVal Ptr As Long) As Long
Public Declare Function lstrlenA Lib "KERNEL32" _
  (ByVal Ptr As Any) As Long
Public Declare Function LocalAlloc Lib "KERNEL32" _
   (ByVal uFlags As Long, _
    ByVal uBytes As Long) As Long
Public Declare Function LocalFree Lib "KERNEL32" _
   (ByVal hMem As Long) As Long
Public Sub cancella_internet_cache()
'-----------------------------------------------------------------
' -- Provvede alla cancellazione della cache di internet explorer.
'    Vengono cancellati tutti i file locali ad eccezzione dei cookie
'    Funziona solo con IE full versione dalla versione 5.5
'-----------------------------------------------------------------
Dim aCache() As Variant
Dim CacheFile As String
Dim i As Long
On Error GoTo errore
  ' -- Estrae tutti i file in cache
  aCache = GetCacheURLList
  'if is not a array exit  ...
  If Not IsArray(aCache) Then Exit Sub
  'delete all files except..
   For i = 0 To UBound(aCache)
      CacheFile = aCache(i)
     ' -- Se il file di cache č un cookie viene risparmiato per salvare
eventuali
     '    password interne
      If InStr(CacheFile, "Cookie") = 0 Then
         Call DeleteUrlCacheEntry(CacheFile)
      End If
   Next
   Exit Sub
errore:
exit sub
End Sub
Private Function GetCacheURLList() As Variant
'-----------------------------------------------------------------
' -- Estrae la lista della cache internet
'-----------------------------------------------------------------
   Dim ICEI As INTERNET_CACHE_ENTRY_INFO
   Dim hFile As Long
   Dim lngCacheCount As Long
   Dim aCacheFile() As Variant
   Dim CacheFile As String
   Dim posUrl As Long
   Dim posEnd As Long
   Dim dwBuffer As Long
   Dim pntrICE As Long
  dwBuffer = 0
   hFile = FindFirstUrlCacheEntry(0&, ByVal 0, dwBuffer)
   If (hFile = ERROR_CACHE_FIND_FAIL) And _
      (Err.LastDllError = ERROR_INSUFFICIENT_BUFFER) Then
   pntrICE = LocalAlloc(LMEM_FIXED, dwBuffer)
      If pntrICE Then
         CopyMemory ByVal pntrICE, dwBuffer, 4
         hFile = FindFirstUrlCacheEntry(vbNullString, ByVal pntrICE,
dwBuffer)
         If hFile <> ERROR_CACHE_FIND_FAIL Then
           lngCacheCount = 0
            Do
                CopyMemory ICEI, ByVal pntrICE, Len(ICEI)
               If (ICEI.CacheEntryType And _
                   NORMAL_CACHE_ENTRY) = NORMAL_CACHE_ENTRY Then
                  CacheFile = GetStrFromPtrA(ICEI.lpszSourceUrlName)
                  ReDim Preserve aCacheFile(0 To lngCacheCount)
                  aCacheFile(lngCacheCount) = CacheFile
                  lngCacheCount = lngCacheCount + 1
               End If
               Call LocalFree(pntrICE)
               dwBuffer = 0
               Call FindNextUrlCacheEntry(hFile, ByVal 0, dwBuffer)
               pntrICE = LocalAlloc(LMEM_FIXED, dwBuffer)
               CopyMemory ByVal pntrICE, dwBuffer, 4
            Loop While FindNextUrlCacheEntry(hFile, ByVal pntrICE, dwBuffer)
         End If 'hFile
      End If 'pntrICE
   End If 'hFile
   Call LocalFree(pntrICE)
   Call FindCloseUrlCache(hFile)
   GetCacheURLList = aCacheFile
End Function
Private Function GetStrFromPtrA(ByVal lpszA As Long) As String
   GetStrFromPtrA = String$(lstrlenA(ByVal lpszA), 0)
   Call lstrcpyA(ByVal GetStrFromPtrA, ByVal lpszA)
End Function

 ha scritto nel messaggio
news:brmd6h$49s$1...@grillo.cs.interbusiness.it...


 Che fare???
sono file in uso da Windows che non li cancella
(e' come la storiella del ramo da segare essendoci seduti)
fatti (anche al volo) un *.bat
questo e quello che adopero io (controlla i percorsi)
ed adopera solo la parte smartdrv+cookies
smartdrv
deltree /y C:\WINDOWS\TEMPOR~1
deltree /y c:\windows\cronol~1
deltree /y c:\windows\Temp
deltree /y c:\windows\Cookies
cd ..
Pause
win/z
--
Fosco