Seite 1 von 1

Probleme mit CallCOM

Verfasst: 19.09.2004 09:22
von Darky
:? Tach wieder mal,
ich hatte einen thread gelesen wo mir gesagt wurde
wie ich den internet-verlauf leere! Was schön aussah! :allright:

Doch wenn ich dieses beispiel aufrufen will bekomme ich eine
Meldung das die Funktion CallCOM nicht gefunden wird ?
brauch ich dafür eine Library und wenn Ja wo kriege ich diese ?


Grüsse aus dem Schönen Soest
<) Darky

Verfasst: 23.09.2004 22:10
von sbehrens
Nimm doch einfach das hier:
http://www.purearea.net/pb/CodeArchiv/I ... lDelete.pb

Code: Alles auswählen

; English forum: http://purebasic.myforums.net/viewtopic.php?t=8182&highlight=
; Author: Hi-Toro
; Date: 06. November 2003

; Well, let's see if this works for everyone (MSDN says it works on all
; versions of Windows with IE4.0+)... 

; The default demo code just lists the files, so don't be afraid! 

; More info here for anyone who wants to explore further: 
; http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wininet/wininet/wininet_functions.asp 


; ----------------------------------------------------------------------------- 
; Internet Explorer cache file enumeration (with optional deletion)... 
; ----------------------------------------------------------------------------- 
; james @ hi - toro . com 
; ----------------------------------------------------------------------------- 

; Cache entry structure... 

Structure INTERNET_CACHE_ENTRY_INFO 
    dwStructSize.l 
    lpszSourceUrlName.s 
    lpszLocalFileName.s 
    CacheEntryType.l 
    dwUseCount.l 
    dwHitRate.l 
    dwSizeLow.l 
    dwSizeHigh.l 
    LastModifiedTime.FILETIME 
    ExpireTime.FILETIME 
    LastAccessTime.FILETIME 
    LastSyncTime.FILETIME 
    *lpHeaderInfo.l 
    dwHeaderInfoSize.l 
    lpszFileExtension.s 
    StructureUnion 
        dwReserved.l 
        dwExemptDelta.l 
    EndStructureUnion 
EndStructure 

; Library number we'll use for wininet.dll... 

#WININET = 9998 

Procedure ListCacheEntries (delete) 

    ; Open wininet.dll... 

    If OpenLibrary (#WININET, "wininet.dll") 

        ; First call must fail in order to get size required for structure's buffer (fbuffsize)... 
        
        enum = CallFunction (#WININET, "FindFirstUrlCacheEntryA", #Null, @fail, @fbuffsize) 
        
        If enum = #Null 
        
            ; Need larger buffer... 
            
            If GetLastError_ () = #ERROR_INSUFFICIENT_BUFFER 
            
                ; Allocate a buffer of the required size, with cache entry structure... 
                    
                mem1 = AllocateMemory (fbuffsize) 
                *ic.INTERNET_CACHE_ENTRY_INFO = mem1
                
                ; Try again with new size and buffer... 
                
                enum = CallFunction (#WININET, "FindFirstUrlCacheEntryA", #Null, *ic.INTERNET_CACHE_ENTRY_INFO, @fbuffsize) 
                
                If enum <> #Null 
                
                    ; Got first cache entry! 
                        
                    Debug *ic\lpszSourceUrlName    ; URL 
                    Debug *ic\lpszLocalFileName     ; Local cache file 

                    ; Delete cache entry if delete parameter = #TRUE... 

                    If delete 
                        If CallFunction (#WININET, "DeleteUrlCacheEntry", *ic\lpszSourceUrlName) 
                            Debug "(Deleted)" 
                        Else 
                            Debug "(Failed to delete)" 
                        EndIf 
                    EndIf 
                    
                    Debug "" 

                    ; Release the buffer... 
                    
                    FreeMemory (mem1) 

                    ; Now iterate through the rest... 
                    
                    *ic = #Null ; Being a good citizen since I intend to use this pointer again... 
                    
                    Repeat 

                        ; *ic is #NULL on the first call, and nbuffsize is 0 (it will be given correct value if there is an entry)... 
                        
                        result = CallFunction (#WININET, "FindNextUrlCacheEntryA", enum, *ic.INTERNET_CACHE_ENTRY_INFO, @nbuffsize) 

                        If result = #False 

                            ; Failed, so was it due to insufficient buffer, or end of cache entries? 
                            
                            error = GetLastError_ () 

                            Select error 

                                Case #ERROR_NO_MORE_ITEMS 

                                    ; End of cache entries -- 'done' variable is used to exit Repeat... Until loop... 

                                    done = #True 

                                Case #ERROR_INSUFFICIENT_BUFFER 

                                    ; nbuffsize was 0, so allocate buffer (FindNextUrlCacheEntryA gave nbuffsize the correct value)... 
                                    
                                    mem2 = AllocateMemory (nbuffsize) 
                                    *ic.INTERNET_CACHE_ENTRY_INFO = mem2

                                    ; (This will then hit 'Until' and go back to 'Repeat', calling the function with a buffer, plus correct nbuffsize.) 
                                    
                            EndSelect 

                        Else 

                            ; FindNextUrlCacheEntryA returned #TRUE in 'result' variable... 
                            
                            Debug *ic\lpszSourceUrlName 
                            Debug *ic\lpszLocalFileName 

                            ; Delete cache entry if delete parameter = #TRUE... 
                            
                            If delete 
                                If CallFunction (#WININET, "DeleteUrlCacheEntry", *ic\lpszSourceUrlName) 
                                    Debug "(Deleted)" 
                                Else 
                                    Debug "(Failed to delete)" 
                                EndIf 
                            EndIf 
                            
                            Debug "" 

                            ; Free this buffer now... 
                            
                            FreeMemory (mem2) 
                            
                            ; Reset nbuffsize to 0 so next FindNextUrlCacheEntryA will fail and allocate buffer as before... 
                            
                            nbuffsize = 0 

                        EndIf 

                    Until done 
                    
                    ; Release cache enumeration handle... 

                    CallFunction (#WININET, "FindCloseUrlCache", enum) 
                    
                EndIf 
                
            EndIf 
            
        EndIf 

        ; Close wininet.dll... 
        
        CloseLibrary (#WININET) 
        
    EndIf 

EndProcedure 

; D E M O . . . 

; Pass '1' instead to delete all cache files (use at own risk, but works fine here!)... 

ListCacheEntries (0) 


; ExecutableFormat=Windows
; EOF
(Von www.PureArea.net)
Der Code ist etwas umgeändert; AllocateMemory(), FreeMemory und am Anfang stand "#WININET = #9998" und ich glaube der Autor meinte "#WININET = 9998" Der Code funktioniert bei mir einwandfrei.

mfG
Basti