Hi all. I am not sure if the trouble I'm running into is Interop related or related to the WPD API specifically. I've this is posted in the wrong forum, please feel free to move it.
In any case, I am working on a C# application that uses WPD and am having trouble with the
GetDevices method mentioned in the title. The initial problem was that I was only able to get one device ID even if multiple devices were connected to the machine. I followed the discussion here and here and
found that modifying the IL for the Interop wrapper from:
} // end of method IPortableDeviceManager::GetDevices
and found that this got me to a point where I was able to get device IDs for all of the devices connected to the machine (not just the first one). However, this only worked once. On subsequent calls, I could retrieve the count properly but only the first
device ID string would be valid. The rest would be null. I even tried changing string to native int in the IL, and then marshalling the strings in manually and ended up with the same result.
Anyone encountered this before? It seems like this must be an issue with the method itself. However, I'm still fairly new to C# Interop so it's possible I'm not properly marshaling the array of strings (actually the native type is LPWSTR*, a pointer to an
array of string pointers). Any help is appreciated.