none
how to get value from an IntPtr pointing to an int pointer RRS feed

  • Question

  • Subject line is what is the question is...

    I am calling an Win32 API that returns pointer to the integer value into IntPtr, how to get the integer value from it?


    BRS
    Thursday, October 16, 2008 1:53 PM

Answers

  •  That'll get the value of the pointer not the value to pointer is pointing to. Marshal.ReadInt32 should do the trick.
    • Marked as answer by nobugzModerator Thursday, October 16, 2008 3:44 PM
    • Unmarked as answer by BRSr Friday, October 17, 2008 6:26 AM
    • Marked as answer by BRSr Friday, October 17, 2008 6:35 AM
    Thursday, October 16, 2008 2:56 PM

  • Thanks Ray,
    I tried the following unsafe code, this also works

    int *res = (int*)intPointer;

    Regards,

    BRS
    • Marked as answer by BRSr Friday, October 17, 2008 6:35 AM
    Friday, October 17, 2008 6:34 AM

All replies

  • Are you searching for IntPtr.ToInt32 method?

    José Tavares
    Thursday, October 16, 2008 2:46 PM
  •  That'll get the value of the pointer not the value to pointer is pointing to. Marshal.ReadInt32 should do the trick.
    • Marked as answer by nobugzModerator Thursday, October 16, 2008 3:44 PM
    • Unmarked as answer by BRSr Friday, October 17, 2008 6:26 AM
    • Marked as answer by BRSr Friday, October 17, 2008 6:35 AM
    Thursday, October 16, 2008 2:56 PM

  • Thanks Ray,
    I tried the following unsafe code, this also works

    int *res = (int*)intPointer;

    Regards,

    BRS
    • Marked as answer by BRSr Friday, October 17, 2008 6:35 AM
    Friday, October 17, 2008 6:34 AM