PORTS Forum

Ports and Interfaces => USB => Topic started by: vanweric on January 10, 2012, 06:25:18 pm

Title: IntPtr <-> Int32 safety
Post by: vanweric 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;
Title: Re: IntPtr <-> Int32 safety
Post by: Jan Axelson on January 10, 2012, 06:28:29 pm
Thank you for the suggestion!

Jan