C # ULONG_PTR Equivalent

I need to pass ULONG_PTR to insecure C # code.

I understand that the reason for ULONG_PTR is to create a single code base for 32-bit and 64-bit operating systems.

Is this the case for C # UIntPtr ? Can I be sure to pass .Net UIntPtr as the ULONG_PTR parameter?

Thanks!

+6
c # types winapi interop
source share
2 answers

From MSDN :

The IntPtr type is CLS-compatible, but the UIntPtr type is not. Only the IntPtr type is used in a common execution language. The UIntPtr type is mainly for maintaining architectural symmetry with the IntPtr type

Both types can store 32-bit and 64-bit pointers. The preferred type is IntPtr .

+6
source share

Based on the MSDN description, I would say that it should be:

The UIntPtr type is intended as an integer, the size of which depends on the platform. That is, it is expected that an instance of this type will be 32-bit on 32-bit hardware and operating systems and 64-bit on 64-bit hardware and operating systems.

+2
source share

All Articles