Conversion to 64-bit

JohnPapa

Registered User.
Local time
Today, 13:18
Joined
Aug 15, 2010
Messages
1,078
I am having a problem with finding the 64-bit version of the following Declare. I notice that its Lib is "msaccess.exe"

Public Declare Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As Integer) As Long

The function does not exist in Win32API_PtrSafe.txt.

Any ideas?
 
just add a PtrSafe to the declaration:

Code:
Public Declare Ptrsafe Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As Integer) As Long
 
I do not have 64bit, but I tried to convert some code for another user in another thread, so try LongLong or LongPtr in place of Long.
Compare it to the other Declares.
Also you are missing PtrSafe?
 
add both versions and your app will work for everyone ,64 or 32

Code:
#If Win64 Then      'Public Declare PtrSafe Function
     Private Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As LongPtr
 #Else
      Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
#End If
 
add both versions and your app will work for everyone ,64 or 32

Code:
#If Win64 Then      'Public Declare PtrSafe Function
     Private Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As LongPtr
 #Else
      Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
#End If
Assuming you're not targeting A2007, this is not needed.
And hWnd is a LongPtr.
 
I am not targeting anything earlier than A2013. So based on the above, is this the correct syntax


Code:
#If Win64 Then      'Public Declare PtrSafe Function
     Private Declare PtrSafe Function GetSystemMenu Lib "user32" (ByVal hWnd As LongPtr, ByVal bRevert As Long) As LongPtr
 #Else
      Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
#End If

Should hWnd be LongPtr as shown above in red
 
Why not try it and see? :(
The code I tried to amend worked for the most part, just did not allow selection from a folder.
 
1. hWnd is a handle so does need to be LongPtr for 64-bit Access
2. Recommend using #If VBA7 as that works in both bitnesses
3. However, conditional compilation is unnecessary if all users have A2010 or later. You just need:

Code:
Declare PtrSafe Function GetSystemMenu Lib "user32" Alias "GetSystemMenu" (ByVal hwnd As LongPtr, ByVal bRevert As Long) As LongPtr

See my article (part of a series of 5):
 
If you look at #1 the original question was about

Public Declare Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As Integer) As Long

It got switched to something else in #4
 
did you try any of those suggested?
if you can't make it work, maybe upload a db (blank) with all those functions/API.
 
In addition to

Public Declare Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As Integer) As Long

I found another one as follows

Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long

Edit:
I searched for CopyFile and found


Declare Function CopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
 
Last edited:
did you try any of those suggested?
if you can't make it work, maybe upload a db (blank) with all those functions/API.
As I mentioned in #9 the original declaration #1 was changed in #4, so the suggestion was not for the correct declaration.

I am trying to change a big 32-bit program to 64-bit.

I could be wrong, during testing it may work for some data and not work for other.
 
The API is similar to this other one:
Public Declare PtrSafe Function GetFileInformationByHandle Lib "kernel32" Alias "GetFileInformationByHandle" (ByVal hFile As LongPtr, lpFileInformation As BY_HANDLE_FILE_INFORMATION) As Long
so I guess the VBA7 version would be:
Public Declare PtrSafe Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As LongPtr) As Long
 
If you look at #1 the original question was about

Public Declare Function ezGetFileInfo Lib "msaccess.exe" Alias "#56# (FSI As ezGetFileInfo, ByVal fOpen As Integer) As Long

It got switched to something else in #4
That was an example? :(
 
you only need to add PtrSafe if there is no Window handle on the function/sub:
Code:
#If VBA7 Then
Declare Function PtrSafe apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long

#Else
Declare Function apiCopyFile Lib "kernel32" Alias "CopyFileA" _
(ByVal lpExistingFileName As String, _
ByVal lpNewFileName As String, _
ByVal bFailIfExists As Long) As Long
 
you might as well upload your db.
putting the Correct declaration is no guarantee that the code will work.
since some of your declaration now has LongPtr on them, some
Variables on your Local Subs/Function should also be converted to LongPtr.
 
you might as well upload your db.
putting the Correct declaration is no guarantee that the code will work.
since some of your declaration now has LongPtr on them, some
Variables on your Local Subs/Function should also be converted to LongPtr.
The .accdb is 75Mb!
 
Finally, I managed to change everything with no compile errors. Will now do some testing.
 

Users who are viewing this thread

Back
Top Bottom