Solved

Declare Function DeleteUrlCacheEntry 64 bit system

Posted on 2014-01-20
6
1,510 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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
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…

749 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