How to get DeleteUrlCacheEntry () error codes? (Or more information on why a particular deletion does not work)?

Basically, when I call DeleteUrlCacheEntry (which is part of the Wininet.dll API), I either return the number 1 (which means that the removal is successful) or the number 0 (this means that the removal does not work).

My question is, how can I find out why the removal did not work? (that is, when 0 is returned). I heard that in C ++ there is a GetLastError () function, however I am using VB6, and apparently the equivalent of GetLastError in VB6 is the Err.LastDllError property.

After trying to delete DeleteUrlCacheEntry, it fails (returns 0) I call / query Err.LastDllError and always returns 0 - no matter what. It returns 0, even if DeleteUrlCacheEntry returns 0 (deletion does not work), and even when it returns 1 (deletion did the job). I also make a call / query in Err.LastDllError as soon as possible (as in, right after calling DeleteUrlCacheEntry).

I'm really confused because I don't even get a runtime error or some typical exception (or any exception for that matter). I don’t have On Error Resume Next to ignore the exception anywhere in my application, therefore all error messages are available, but I can’t understand for life why a particular DeleteUrlCacheEntry () attempt will fail and return 0 (it seems to me that there can be no way to find out).

So my question is: how to get extended error information from the DeleteUrlCacheEntry () function (located in the wininet.dll API)?

If you need more information about the reason why I was looking for additional error information from the DeleteUrlCacheEntry () function, I have another question that describes this in detail (along with the actual examples of cache elements that work and do not work when an attempt is made to delete ): https://stackoverflow.com/questions/1783298/ ...

Also, just to add, I use VB6, but basically it should be the same in most languages, since this is an API call. Here is my ad in VB6:

Public declaration Function DeleteUrlCacheEntry Lib "WININET" Alias ​​"DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) Longer

In addition, I call it as follows:

Dim lReturnValue As Long

Dim cacheFileString As String

'GetStrFromPtrA () . cacheFileString - / lpszSourceUrlName, (Long) String (/ /). , cacheFileString FindFirst/NextEntry , - , .

cacheFileString = GetStrFromPtrA (icei.lpszSourceUrlName)

lReturnValue = UrlCacheEntry (cacheFileString)

lReturnValue 0, , 1, , . , Err.LastDllError 0.

.

+2
4

DeleteUrlCacheEntry() , , .

, .

+1

Err.LastDllError 0, GetLastError() 0, , VB GetLastError(), . , VB DeleteUrlCacheEntry() , , DllImport.SetLastError true .NET PInvoke.

+1

, , . , :

Public Declare Function DeleteUrlCacheEntry Lib "WININET" Alias "DeleteUrlCacheEntryA" (ByVal lpszUrlName As Long) As Long

Dim lReturnValue As Long

lReturnValue = DeleteUrlCacheEntry(icei.lpszSourceUrlName)

(, icei.lpszSourceUrlName ANSI.)

, , Err.LastDllError , , VB, declare usegetlasterror = true? , , APIFunc1() APIFunc2(), :

nRet = APIFunc1(APIFunc2)

... LastDllError APIFunc1().

+1

... , .

, DeleteUrlCacheEntry URL-, , Err.LastDllError 2!

-1

Source: https://habr.com/ru/post/1783298/


All Articles