How to adopt function DeleteUrlCacheEntry in HMG

Other General Resources like icon sets, sound files etc.,

Moderator: Rathinagiri

Post Reply
User avatar
bpd2000
Posts: 1017
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 164 times
Been thanked: 72 times

How to adopt function DeleteUrlCacheEntry in HMG

Post by bpd2000 » Sun Jun 17, 2018 8:18 am

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
BPD
Convert Dream into Reality through HMG

KDJ
Posts: 206
Joined: Mon Sep 05, 2016 3:04 am
Location: Poland
Been thanked: 243 times

Post by KDJ » Sun Jun 17, 2018 12:16 pm

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

User avatar
srvet_claudio
Posts: 2018
Joined: Thu Feb 25, 2010 8:43 pm
Location: Uruguay
Has thanked: 34 times
Been thanked: 143 times
Contact:

Post by srvet_claudio » Mon Jun 18, 2018 1:33 am

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
Best regards.
Dr. Claudio Soto
(from Uruguay)
http://srvet.blogspot.com

User avatar
bpd2000
Posts: 1017
Joined: Sat Sep 10, 2011 4:07 am
Location: India
Has thanked: 164 times
Been thanked: 72 times

Post by bpd2000 » Mon Jun 18, 2018 3:38 am

Thank you Krzysztof
Thank you Dr. Claudio
BPD
Convert Dream into Reality through HMG

Post Reply