Solved

Declare Function DeleteUrlCacheEntry 64 bit system

Posted on 2014-01-20
6
1,406 Views
Last Modified: 2014-01-23
I am using the following function in one of my databases that needs to run on both 32 bit and 64 bit systems. Two questions:
1)   Is there any way to modify it so it will run on both, or do I need different front ends for each version?
2)  What do I need to do to make it run on a 64 bit version of MS Access (2010)?

Private Declare Function DeleteUrlCacheEntry Lib "wininet" Alias _
    "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
"URLDownloadToFileA" (ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
0
Comment
Question by:Rob4077
  • 3
  • 3
6 Comments
 
LVL 12

Accepted Solution

by:
pdebaets earned 500 total points
ID: 39793738
You can use the VBA7 compiler directive constant to determine which block of code to compile in the different environments.

Try this:

#if VBA7 then
    Private Declare PtrSafe Function DeleteUrlCacheEntry Lib "wininet" Alias _
        "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

    Private Declare PtrSafe Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As LongPtr, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As LongPtr) As LongPtr
#else
    Private Declare Function DeleteUrlCacheEntry Lib "wininet" Alias _
        "DeleteUrlCacheEntryA" (ByVal lpszUrlName As String) As Long

    Private Declare Function URLDownloadToFile Lib "urlmon" Alias _
    "URLDownloadToFileA" (ByVal pCaller As Long, _
    ByVal szURL As String, _
    ByVal szFileName As String, _
    ByVal dwReserved As Long, _
    ByVal lpfnCB As Long) As Long
#end if

Open in new window

0
 

Author Comment

by:Rob4077
ID: 39793869
That appears to work on my 32 bit version at home. I will confirm it on the 64 bit version at the office tomorrow before I close the question. Thanks very much for your help
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 39794549
Your URLDownloadToFile function will return a LongPtr value in Access 2010. So you may need additional code changes such as

#if VBA7 then
dim ReturnVal as LongPtr
#Else
dim ReturnVal as Long
#end if

ReturnVal = URLDownloadToFile(...
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:Rob4077
ID: 39795729
Can I just change it to Single instead of LongPtr/Long ?
0
 
LVL 12

Expert Comment

by:pdebaets
ID: 39795823
No.
0
 

Author Comment

by:Rob4077
ID: 39802858
All works perfectly. Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now