COnvert 32 bit API to 64 bit - Pointers and Handles

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
Furthermore, according to this article:


it states if the O/S is 64 bit but Office is 32 bit, use this:

Rich (BB code):
#If  Win64 Then
    Declare PtrSafe Function GetTickCount64 Lib "kernel32"() As LongLong
#Else 
    Declare PtrSafe Function GetTickCount Lib "kernel32" () As Long
#End  If

but if both the O/S and Office are 64 bit, use this:

Rich (BB code):
#If  VBA7 Then
   Declare PtrSafe Function FindWindow Lib "user32" Alias "FindWindowA" ( _
       ByVal lpClassName As String, _
       ByVal lpWindowName As String) As LongPtr
 #Else 
   Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal _
       lpClassName As String, ByVal lpWindowName As String) As Long
#End  If

Is there some code that'll work for both because I don't know if my users are on 32 bit or 64 bit (O/S and Office)?
 
Last edited:
Upvote 0
A Handle is a reference to a Windows object and a Pointer is a memory address of an object.

Examples of Handles and Pointers :

Hwnd: a handle of a UI Window returned by the FindWindow API function or hDC: a handle of a Device Context returned by the GetDc API ..

Pointers are also returned by functions such as ObjPtr,StrPtr,VarPtr or by the AddressOf operator and are often returned by OUT API arguments.

Handles and Pointers are 32bit (long) in 32bit systems and 64bit long (LongLong/LongPtr) in 64Bit systems.

Is there some code that'll work for both because I don't know if my users are on 32 bit or 64 bit (O/S and Office)?

Yes that is why you see the #If #Else #End If conditional compilation clause.

Check out this page for Declare statements for many functions in the Microsoft Windows API for use with Visual Basic for Applications (VBA)
and Microsoft Office 2010-2016 on 32-bit (x86) and 64-bit (x64) platforms http://www.cadsharp.com/docs/Win32API_PtrSafe.txt
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,894
Messages
6,175,250
Members
452,623
Latest member
Techenthusiast

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