Page 1 of 1

How to adopt function DeleteUrlCacheEntry in HMG

Posted: Sun Jun 17, 2018 8:18 am
by bpd2000
How to adopt function DeleteUrlCacheEntry in HMG
That removes the file associated with the source name from the cache, if the file exists.
Syntax C++:

BOOLAPI DeleteUrlCacheEntry(
_In_ LPCTSTR lpszUrlName
);

https://msdn.microsoft.com/en-us/librar ... s.85).aspx

Re: How to adopt function DeleteUrlCacheEntry in HMG

Posted: Sun Jun 17, 2018 12:16 pm
by KDJ
For example, in this way:

Code: Select all

#include "hmg.ch"

MEMVAR _HMG_SYSDATA

FUNCTION Main()
  LOCAL cURL := "http://myURL"
  LOCAL nError

  IF DeleteUrlCacheEntry(cURL, @nError)
    MsgBox("Deleted!")
  ELSE
    //System Error Codes: https://msdn.microsoft.com/en-us/library/windows/desktop/ms681381(v=vs.85).aspx
    MsgBox("Error code: " + HB_NtoS(nError))
  ENDIF

RETURN NIL

#pragma BEGINDUMP
#include <windows.h>
#include <Wininet.h>
#include "hbapi.h"
#include "SET_COMPILE_HMG_UNICODE.ch"
#include "HMG_UNICODE.h"

      // DeleteUrlCacheEntry(cURL[, @nError])
HB_FUNC( DELETEURLCACHEENTRY )
{
  BOOL  bRetVal = DeleteUrlCacheEntry((LPCTSTR) HMG_parc(1));
  DWORD nError  = GetLastError();

  if (HB_ISBYREF(2))
    hb_stornl(nError, 2);

  hb_retl(bRetVal);
}
#pragma ENDDUMP

Re: How to adopt function DeleteUrlCacheEntry in HMG

Posted: Mon Jun 18, 2018 1:33 am
by srvet_claudio
A comment:
these header files should always go first

#include "SET_COMPILE_HMG_UNICODE.ch" #include "HMG_UNICODE.h"

because they activate / deactivate compilation in Unicode in the other header files

Re: How to adopt function DeleteUrlCacheEntry in HMG

Posted: Mon Jun 18, 2018 3:38 am
by bpd2000
Thank you Krzysztof
Thank you Dr. Claudio