Search notes:

VBA: 32-bit vs 64-bit

The longPtr data type is 4 bytes in a 32-bit environment (of Office) and 8 bytes in a 64-bit environment.
The longLong data type is only defined in 64-bit environments, see testing for 64-bit environments.
In a 64-bit environment, the compiler directive constant win64 is predefined, see also here.

ptrSafe keyword

The ptrSafe keyword makes sure that a can be safely run in a 64 bit-environment.
64-bit versions of Office (or the VBA runtime) require a declare statement to be decorated with ptrSafe.
I believe (but would like to have this confirmed or refuted) that the idea of ptrSafe is to force a developer to think about the data types that need to be adjusted when moving from 32 bit to 64 bit. By declaring a function with ptrSafe, the developer explicitly states that the necessary changes to longLong and longPtr have been performed.
The ptrSafe can be conditionally applied to a declare statement by using #if … then … #end if conditional compilation constructs:
#if vba7 then 
    declare ptrsafe sub … 
#else 
    declare         sub …
#endif

See also

The ptrSafe attribute of a declare statement.
In Visual Basic for Application, the bitness of the Office application can be determined with the win16, win32 and win64 predefined directive constants.
MS Office: 32 bit vs 64 bit
At least in Excel, the operatingSystem property of the application object returns a string (for example Windows (32-bit) NT 10.00) which allows to infer the bitness of the operating system that the code runs on.
WOW64

Index