More problems with 64 bit transition

davidam

Active Member
Joined
May 28, 2010
Messages
497
Office Version
  1. 2021
Platform
  1. Windows
Hello All,
I gather from reading online that changing Long declarations to LongPtr is not correct in some situations. Can someone help me with the following declarations:
VBA Code:
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
  (ByVal hInet As LongPtr) As Integer
 
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _
(ByVal hInternetSession As LongPtr, ByVal sServerName As String, _
ByVal nServerPort As Integer, _
ByVal sUserName As String, ByVal sPassword As String, ByVal lService As LongPtr, _
ByVal lFlags As LongPtr, ByVal lContext As LongPtr) As LongPtr
 
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _
 (ByVal sAgent As String, ByVal lAccessType As LongPtr, ByVal sProxyName As String, _
ByVal sProxyBypass As String, ByVal lFlags As LongPtr) As LongPtr
 
Private Declare Function FtpSetCurrentDirectory Lib "wininet.dll" Alias _
"FtpSetCurrentDirectoryA" (ByVal hFtpSession As LongPtr, _
ByVal lpszDirectory As String) As Boolean

Private Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" _
(ByVal hConnect As LongPtr, ByVal lpszRemoteFile As String) As Boolean

Private Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _
(ByVal hConnect As LongPtr, ByVal lpszRemoteFile As String, _
ByVal lpszNewFile As String, ByVal fFailIfExists As LongPtr, _
ByVal dwFlagsAndAttributes As LongPtr, ByVal dwFlags As LongPtr, _
ByRef dwContext As LongPtr) As Boolean
 
Private Declare Function FtpPutFile Lib "wininet.dll" Alias _
"FtpPutFileA" (ByVal hConnect As LongPtr, ByVal lpszLocalFile As String, _
ByVal lpszNewRemoteFile As String, ByVal dwFlags As LongPtr, _
ByVal dwContext As LongPtr) As Boolean


Thank you,
David
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
You can't just plunk in LongPtr wherever you see Long if that's what you did. Also, pretty sure you must declare as
Private Declare PtrSafe Function ... but I believe you can omit Private if you need to.
more info
 
Upvote 0
Solution
Pay special attention when referencing pointers and handles.
Pointers and handles in 64-bit environments are 8-byte 64-bit quantities, so use LongPtr for those.
And to find out whether an api return or argument(s) are pointers or handles, refer to the api definition in the MS documentation.
 
Upvote 0
Thanks to Micron; I did miss this step and it has resolved everything.
Thanks to Jaafar Tribak as I will follow up on this suggestion.
Cheers All!
 
Upvote 0

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,632
Latest member
jladair

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top