IntPtr (user32)
Last changed: Damon Carr-72.43.165.29

.
Summary
An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.

C# Signature:

// NATIVE SUPPORT
IntPtr handle;

VB Signature:

Declare Function IntPtr Lib "user32.dll" (TODO) As TODO

User-Defined Types:

None.

Notes:

None.

Tips & Tricks:

An IntPtr is a pointer to a memory location (unmanaged) that adapts to the platform it is running on (64-bit, etc.) UNLIKE a standard int/Integer. You should always use this type for unmanaged calls that require it, even though an int will appear to work on your development machine.

Sample Code:

        // A Windows Service example.

       IntPtr handle = this.ServiceHandle;

        myServiceStatus.currentState = (int)State.SERVICE_START_PENDING;   //0x00000002
        myServiceStatus.checkPoint = 1;
        myServiceStatus.waitHint = 5000;
        SetServiceStatus(handle, ref myServiceStatus);

Alternative Managed API:

This is not so much an API as a .NET (value) data type.

Documentation
IntPtr on MSDN