Accueil > > > VIDER LE CACHE INTERNET (VB.NET 2003)
VIDER LE CACHE INTERNET (VB.NET 2003)
Information sur la source
Description
Adaptation d'un source C# de la MSDN de Microsoft : Suppression du cache d'internet explorer en VB.NET 2003
Source
- Imports System
- Imports System.Runtime.InteropServices
- Public Class clsIE
- ' Indicates that all of the cache groups in the user's system should be enumerated
- Const CACHEGROUP_SEARCH_ALL As Integer = &H0
- ' Indicates that all the cache entries that are associated with the cache group
- ' should be deleted, unless the entry belongs to another cache group.
- Const CACHEGROUP_FLAG_FLUSHURL_ONDELETE As Integer = &H2
- ' File not found.
- Const ERROR_FILE_NOT_FOUND As Integer = &H2
- ' No more items have been found.
- Const ERROR_NO_MORE_ITEMS As Integer = 259
-
- ' For PInvoke: Contains information about an entry in the Internet cache
- <StructLayout(LayoutKind.Explicit, Size:=80)> _
- Public Structure INTERNET_CACHE_ENTRY_INFOA
- <FieldOffset(0)> Public dwStructSize As Short
- <FieldOffset(4)> Public lpszSourceUrlName As IntPtr
- <FieldOffset(8)> Public lpszLocalFileName As IntPtr
- <FieldOffset(12)> Public CacheEntryType As Short
- <FieldOffset(16)> Public dwUseCount As Short
- <FieldOffset(20)> Public dwHitRate As Short
- <FieldOffset(24)> Public dwSizeLow As Short
- <FieldOffset(28)> Public dwSizeHigh As Short
- <FieldOffset(32)> Public LastModifiedTime As FILETIME
- <FieldOffset(40)> Public ExpireTime As FILETIME
- <FieldOffset(48)> Public LastAccessTime As FILETIME
- <FieldOffset(56)> Public LastSyncTime As FILETIME
- <FieldOffset(64)> Public lpHeaderInfo As IntPtr
- <FieldOffset(68)> Public dwHeaderInfoSize As Short
- <FieldOffset(72)> Public lpszFileExtension As IntPtr
- <FieldOffset(76)> Public dwReserved As Short
- <FieldOffset(76)> Public dwExemptDelta As Short
- End Structure
-
- ' For PInvoke: Initiates the enumeration of the cache groups in the Internet cache
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="FindFirstUrlCacheGroup", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function FindFirstUrlCacheGroup( _
- ByVal dwFlags As Integer, _
- ByVal dwFilter As Integer, _
- ByVal lpSearchCondition As IntPtr, _
- ByVal dwSearchCondition As Integer, _
- ByRef lpGroupId As Long, _
- ByVal lpReserved As IntPtr) As IntPtr
- End Function
- ' For PInvoke: Retrieves the next cache group in a cache group enumeration
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="FindNextUrlCacheGroup", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function FindNextUrlCacheGroup( _
- ByVal hFind As IntPtr, _
- ByRef lpGroupId As Long, _
- ByVal lpReserved As IntPtr) As Boolean
- End Function
-
- ' For PInvoke: Releases the specified GROUPID and any associated state in the cache index file
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="DeleteUrlCacheGroup", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function DeleteUrlCacheGroup( _
- ByVal GroupId As Long, _
- ByVal dwFlags As Integer, _
- ByVal lpReserved As IntPtr) As Boolean
- End Function
-
- ' For PInvoke: Begins the enumeration of the Internet cache
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="FindFirstUrlCacheEntryA", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function FindFirstUrlCacheEntry( _
- <MarshalAs(UnmanagedType.LPTStr)> ByVal lpszUrlSearchPattern As String, _
- ByVal lpFirstCacheEntryInfo As IntPtr, _
- ByRef lpdwFirstCacheEntryInfoBufferSize As Integer) As IntPtr
- End Function
- ' For PInvoke: Retrieves the next entry in the Internet cache
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="FindNextUrlCacheEntryA", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function FindNextUrlCacheEntry( _
- ByVal hFind As IntPtr, _
- ByVal lpNextCacheEntryInfo As IntPtr, _
- ByRef lpdwNextCacheEntryInfoBufferSize As Integer) As Boolean
- End Function
-
- ' For PInvoke: Removes the file that is associated with the source name from the cache, if the file exists
- <DllImport("wininet", _
- SetLastError:=True, _
- CharSet:=CharSet.Auto, _
- EntryPoint:="DeleteUrlCacheEntryA", _
- CallingConvention:=CallingConvention.StdCall)> _
- Shared Function DeleteUrlCacheEntry( _
- ByVal lpszUrlName As IntPtr) As Boolean
- End Function
-
- <STAThread()> _
- Public Sub sbDeleteALL(Optional ByVal Args() As String = Nothing)
- Try
- ' Pointer to a GROUPID variable
- Dim groupId As Long = 0
-
- ' Local variables
- Dim cacheEntryInfoBufferSizeInitial As Integer = 0
- Dim cacheEntryInfoBufferSize As Integer = 0
- Dim cacheEntryInfoBuffer As IntPtr = IntPtr.Zero
- Dim internetCacheEntry As INTERNET_CACHE_ENTRY_INFOA
- Dim enumHandle As IntPtr = IntPtr.Zero
- Dim returnValue As Boolean = False
-
- enumHandle = FindFirstUrlCacheGroup(0, CACHEGROUP_SEARCH_ALL, IntPtr.Zero, 0, groupId, IntPtr.Zero)
- If enumHandle.ToInt32 <> IntPtr.Zero.ToInt32 And _
- ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
- Return
- End If
- While (True)
- returnValue = DeleteUrlCacheGroup(groupId, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, IntPtr.Zero)
- If Not returnValue And ERROR_FILE_NOT_FOUND = Marshal.GetLastWin32Error() Then
- returnValue = FindNextUrlCacheGroup(enumHandle, groupId, IntPtr.Zero)
- End If
-
- If Not returnValue And (ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() _
- Or ERROR_FILE_NOT_FOUND = Marshal.GetLastWin32Error()) Then
- Exit While
- End If
- End While
-
- enumHandle = FindFirstUrlCacheEntry(String.Empty, IntPtr.Zero, _
- cacheEntryInfoBufferSizeInitial)
- If enumHandle.ToInt32 <> IntPtr.Zero.ToInt32 And _
- ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
- Return
- End If
-
- cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial
- cacheEntryInfoBuffer = Marshal.AllocHGlobal(cacheEntryInfoBufferSize)
- enumHandle = FindFirstUrlCacheEntry(String.Empty, cacheEntryInfoBuffer, _
- cacheEntryInfoBufferSizeInitial)
-
- While (True)
- internetCacheEntry = Marshal.PtrToStructure(cacheEntryInfoBuffer, _
- GetType(INTERNET_CACHE_ENTRY_INFOA))
-
- cacheEntryInfoBufferSizeInitial = cacheEntryInfoBufferSize
- returnValue = DeleteUrlCacheEntry(internetCacheEntry.lpszSourceUrlName)
- If Not returnValue Then
- returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, _
- cacheEntryInfoBufferSizeInitial)
- End If
- If Not returnValue And ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
- Exit While
- End If
- If Not returnValue And cacheEntryInfoBufferSizeInitial > _
- cacheEntryInfoBufferSize Then
-
- cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial
-
- Dim tempIntPtr As New IntPtr(cacheEntryInfoBufferSize)
- cacheEntryInfoBuffer = Marshal.ReAllocHGlobal(cacheEntryInfoBuffer, _
- tempIntPtr)
- returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, _
- cacheEntryInfoBufferSizeInitial)
- End If
- End While
- Marshal.FreeHGlobal(cacheEntryInfoBuffer)
- Catch ex As Exception
- gMsg.sbMsgCr(ex.Message, "clsIE.sbDeleteALL")
- End Try
- End Sub
- End Class
Imports System
Imports System.Runtime.InteropServices
Public Class clsIE
' Indicates that all of the cache groups in the user's system should be enumerated
Const CACHEGROUP_SEARCH_ALL As Integer = &H0
' Indicates that all the cache entries that are associated with the cache group
' should be deleted, unless the entry belongs to another cache group.
Const CACHEGROUP_FLAG_FLUSHURL_ONDELETE As Integer = &H2
' File not found.
Const ERROR_FILE_NOT_FOUND As Integer = &H2
' No more items have been found.
Const ERROR_NO_MORE_ITEMS As Integer = 259
' For PInvoke: Contains information about an entry in the Internet cache
<StructLayout(LayoutKind.Explicit, Size:=80)> _
Public Structure INTERNET_CACHE_ENTRY_INFOA
<FieldOffset(0)> Public dwStructSize As Short
<FieldOffset(4)> Public lpszSourceUrlName As IntPtr
<FieldOffset(8)> Public lpszLocalFileName As IntPtr
<FieldOffset(12)> Public CacheEntryType As Short
<FieldOffset(16)> Public dwUseCount As Short
<FieldOffset(20)> Public dwHitRate As Short
<FieldOffset(24)> Public dwSizeLow As Short
<FieldOffset(28)> Public dwSizeHigh As Short
<FieldOffset(32)> Public LastModifiedTime As FILETIME
<FieldOffset(40)> Public ExpireTime As FILETIME
<FieldOffset(48)> Public LastAccessTime As FILETIME
<FieldOffset(56)> Public LastSyncTime As FILETIME
<FieldOffset(64)> Public lpHeaderInfo As IntPtr
<FieldOffset(68)> Public dwHeaderInfoSize As Short
<FieldOffset(72)> Public lpszFileExtension As IntPtr
<FieldOffset(76)> Public dwReserved As Short
<FieldOffset(76)> Public dwExemptDelta As Short
End Structure
' For PInvoke: Initiates the enumeration of the cache groups in the Internet cache
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="FindFirstUrlCacheGroup", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function FindFirstUrlCacheGroup( _
ByVal dwFlags As Integer, _
ByVal dwFilter As Integer, _
ByVal lpSearchCondition As IntPtr, _
ByVal dwSearchCondition As Integer, _
ByRef lpGroupId As Long, _
ByVal lpReserved As IntPtr) As IntPtr
End Function
' For PInvoke: Retrieves the next cache group in a cache group enumeration
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="FindNextUrlCacheGroup", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function FindNextUrlCacheGroup( _
ByVal hFind As IntPtr, _
ByRef lpGroupId As Long, _
ByVal lpReserved As IntPtr) As Boolean
End Function
' For PInvoke: Releases the specified GROUPID and any associated state in the cache index file
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="DeleteUrlCacheGroup", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function DeleteUrlCacheGroup( _
ByVal GroupId As Long, _
ByVal dwFlags As Integer, _
ByVal lpReserved As IntPtr) As Boolean
End Function
' For PInvoke: Begins the enumeration of the Internet cache
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="FindFirstUrlCacheEntryA", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function FindFirstUrlCacheEntry( _
<MarshalAs(UnmanagedType.LPTStr)> ByVal lpszUrlSearchPattern As String, _
ByVal lpFirstCacheEntryInfo As IntPtr, _
ByRef lpdwFirstCacheEntryInfoBufferSize As Integer) As IntPtr
End Function
' For PInvoke: Retrieves the next entry in the Internet cache
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="FindNextUrlCacheEntryA", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function FindNextUrlCacheEntry( _
ByVal hFind As IntPtr, _
ByVal lpNextCacheEntryInfo As IntPtr, _
ByRef lpdwNextCacheEntryInfoBufferSize As Integer) As Boolean
End Function
' For PInvoke: Removes the file that is associated with the source name from the cache, if the file exists
<DllImport("wininet", _
SetLastError:=True, _
CharSet:=CharSet.Auto, _
EntryPoint:="DeleteUrlCacheEntryA", _
CallingConvention:=CallingConvention.StdCall)> _
Shared Function DeleteUrlCacheEntry( _
ByVal lpszUrlName As IntPtr) As Boolean
End Function
<STAThread()> _
Public Sub sbDeleteALL(Optional ByVal Args() As String = Nothing)
Try
' Pointer to a GROUPID variable
Dim groupId As Long = 0
' Local variables
Dim cacheEntryInfoBufferSizeInitial As Integer = 0
Dim cacheEntryInfoBufferSize As Integer = 0
Dim cacheEntryInfoBuffer As IntPtr = IntPtr.Zero
Dim internetCacheEntry As INTERNET_CACHE_ENTRY_INFOA
Dim enumHandle As IntPtr = IntPtr.Zero
Dim returnValue As Boolean = False
enumHandle = FindFirstUrlCacheGroup(0, CACHEGROUP_SEARCH_ALL, IntPtr.Zero, 0, groupId, IntPtr.Zero)
If enumHandle.ToInt32 <> IntPtr.Zero.ToInt32 And _
ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
Return
End If
While (True)
returnValue = DeleteUrlCacheGroup(groupId, CACHEGROUP_FLAG_FLUSHURL_ONDELETE, IntPtr.Zero)
If Not returnValue And ERROR_FILE_NOT_FOUND = Marshal.GetLastWin32Error() Then
returnValue = FindNextUrlCacheGroup(enumHandle, groupId, IntPtr.Zero)
End If
If Not returnValue And (ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() _
Or ERROR_FILE_NOT_FOUND = Marshal.GetLastWin32Error()) Then
Exit While
End If
End While
enumHandle = FindFirstUrlCacheEntry(String.Empty, IntPtr.Zero, _
cacheEntryInfoBufferSizeInitial)
If enumHandle.ToInt32 <> IntPtr.Zero.ToInt32 And _
ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
Return
End If
cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial
cacheEntryInfoBuffer = Marshal.AllocHGlobal(cacheEntryInfoBufferSize)
enumHandle = FindFirstUrlCacheEntry(String.Empty, cacheEntryInfoBuffer, _
cacheEntryInfoBufferSizeInitial)
While (True)
internetCacheEntry = Marshal.PtrToStructure(cacheEntryInfoBuffer, _
GetType(INTERNET_CACHE_ENTRY_INFOA))
cacheEntryInfoBufferSizeInitial = cacheEntryInfoBufferSize
returnValue = DeleteUrlCacheEntry(internetCacheEntry.lpszSourceUrlName)
If Not returnValue Then
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, _
cacheEntryInfoBufferSizeInitial)
End If
If Not returnValue And ERROR_NO_MORE_ITEMS = Marshal.GetLastWin32Error() Then
Exit While
End If
If Not returnValue And cacheEntryInfoBufferSizeInitial > _
cacheEntryInfoBufferSize Then
cacheEntryInfoBufferSize = cacheEntryInfoBufferSizeInitial
Dim tempIntPtr As New IntPtr(cacheEntryInfoBufferSize)
cacheEntryInfoBuffer = Marshal.ReAllocHGlobal(cacheEntryInfoBuffer, _
tempIntPtr)
returnValue = FindNextUrlCacheEntry(enumHandle, cacheEntryInfoBuffer, _
cacheEntryInfoBufferSizeInitial)
End If
End While
Marshal.FreeHGlobal(cacheEntryInfoBuffer)
Catch ex As Exception
gMsg.sbMsgCr(ex.Message, "clsIE.sbDeleteALL")
End Try
End Sub
End Class
Sources du même auteur
Sources de la même categorie
Commentaires et avis
Discussions en rapport avec ce code source dans le forum
Effacer les 'temporary internet files' [ par ZeViRuS ]
slt a tousun pote m'a demandé de lui faire un petit navigateur web qui efface aussi les temporary internet filesje n'arrive pas a trouver le codej'ess
Temporary Internet Files [ par casi ]
Comment effacer le contenu de ce dossier par VB ?
Temporary Internet Files [ par casi ]
Comment effacer le contenu de ce dossier par VB ?
Temporary Internet files [ par casi ]
Je cherche à éffacer les fichiers du dossier"Temporary Internet files" par VB ... sans succés (permission refusée).Si vous avez une astuce; je suis pr
Temporary Internet Files [ par donald ]
Salut !Comment vider en VB6 le répertoire :C:\WINDOWS\Temporary Internet FilesMerci et @+
Temporary internet files [ par drudy ]
Comment acceder au objects (gif par exemple) dans le repertoire temporary internet files. Il a une structure bizarre, et même sous dos , rien apparait
|
Derniers Blogs
XNA IS DEAD!XNA IS DEAD! par richardc
Depuis la semaine dernière (et grâce aux TechDays 2012), je me penche activement sur la nouvelle version de Windows, aka Windows 8. Vous me direz, il était temps puisque la première preview date de Septembre dernier.
OK. Remarquez, on n'en est qu'aux...
Cliquez pour lire la suite de l'article par richardc TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 !TECHDAYS PARIS 2012 : WINDOWS SERVER "8" QUOI DE 9 ! par ROMELARD Fabrice
Speakers: Fabrice Meillon et Stanislas Quastana Cette session est basée entièrement sur celle donnée lors de la BUILD cet hiver. Il n'y a pas d'ajout d'information en rapport avec cet évènement passé. Windows 8 Server sera intégralem...
Cliquez pour lire la suite de l'article par ROMELARD Fabrice [HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE)[HTML5] AUTOUR DU W3C : NOUVEAUX STANDARDS ET WEB MOBILE (LILLE) par Gio
Je m'y prends un peu tard je sais, mais bon je suis développeur web et donc hyper fainéant ! Toujours dans le cadre des technologies émergentes, ici HTML5, parce qu'on aime HTML5 chez Wyg , nous seront présent, le vieux ( Aurélien V.) et moi, pour pr...
Cliquez pour lire la suite de l'article par Gio [WP7] DYNAMICALLY CHANGE STARTUP PAGE[WP7] DYNAMICALLY CHANGE STARTUP PAGE par KooKiz
Let's say that you want to allow the user to customize the startup page of your application. You can easily change the startup page by editing the 'NavigationPage' attribute in the manifest file. But the manifest cannot be modified once the applicatio...
Cliquez pour lire la suite de l'article par KooKiz
Logiciels
DocTranslate (V3.1.0.0)DOCTRANSLATE (V3.1.0.0)DocTranslate est un traducteur de document Microsoft Word, PowerPoint et Excel. Il permet d'autom... Cliquez pour télécharger DocTranslate Tribler (2012)TRIBLER (2012)Tribler est un client pair à pair (P2P/Peer-to-Peer) open source avec la capacité de regarder des... Cliquez pour télécharger Tribler OneSwarm (2012)ONESWARM (2012)Le peer-to-peer qui protège votre vie privée, c'est OneSwarm.
Ce logiciel de peer-to-peer crypté... Cliquez pour télécharger OneSwarm PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO (V8.4)PONAMEDIA TV DEVIENS HELLLOOO FLASH
LA TV SUR VOTRE ORDINATEUR.
Toute une plateforme Multi... Cliquez pour télécharger PONAMEDIA PREMIUM - HELLLOOO FLASH DEMO Academy System (17.2.1.0)ACADEMY SYSTEM (17.2.1.0)Logiciel de gestion des établissements.
- élèves/étudiants (inscription, dossier, absence...)
-... Cliquez pour télécharger Academy System
|