Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Support Forum
Download Visual Studio Add-In

Terms of Use
Privacy Policy
IntPtr (user32)
 
.
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:

[DllImport("user32.dll", SetLastError=true)]
static extern TODO IntPtr(TODO);

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

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Find References
Show Printable Version
Revisions