Author Topic: IntPtr <-> Int32 safety  (Read 14736 times)

vanweric

  • Member
  • ***
  • Posts: 24
IntPtr <-> Int32 safety
« on: January 10, 2012, 06:25:18 pm »
Jan -

I noticed this line in one of your demos, and was worried about the type safety:

IntPtr pDevicePathName = new IntPtr(detailDataBuffer.ToInt32() + 4);
(Generic_hid_cs -> DeviceManagement.cs)

In 64 bit environment, this will chop off the high word.  Are we guaranteed that this will be in the lower 4 gigs?

I replaced it with this to be on the safe side:
IntPtr pDevicePathName = detailDataBuffer + 4;

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: IntPtr <-> Int32 safety
« Reply #1 on: January 10, 2012, 06:28:29 pm »
Thank you for the suggestion!

Jan