Solved

Declare Function DeleteUrlCacheEntry 64 bit system

Posted on 2014-01-20
6
1,571 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Get your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Code that checks the QuickBooks schema table for non-updateable fields and then disables those controls on a form so users don't try to update them.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

636 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