05-12-2011 03:55 PM
I am trying to figure out how to detect/enumerate and talk to MTP devices which do not have drive letters.
I have the proper links form MSDN and the functions they suggest, but they do not work in CVI and am not sure how to make them work.
Enumerate - Enumerating WPD Devices or msdn direct link
Connecting - Connecting to a WPD Device
Sending Commands - Sending MTP Commands through WPD
In the past, I have just included the windows.h header and done the following two function prototypes for drive letters.
// Setup function to get present Drive Letters
DWORD WINAPI GetLogicalDriveStrings(__in DWORD nBufferLength,__out LPTSTR lpBuffer);
// Setup function to get Volume Names of Drives
BOOL WINAPI GetVolumeInformation( __in_opt LPCTSTR lpRootPathName, __out LPTSTR lpVolumeNameBuffer, __in DWORD nVolumeNameSize, __out_opt LPDWORD lpVolumeSerialNumber, __out_opt LPDWORD lpMaximumComponentLength, __out_opt LPDWORD lpFileSystemFlags, __out LPTSTR lpFileSystemNameBuffer, __in DWORD nFileSystemNameSize);
However, using
hr = CoCreateInstance(CLSID_PortableDeviceManager,
NULL,
CLSCTX_INPROC_SERVER,
IID_IPortableDeviceManager,
(VOID**) &spDevMgr)
fails with many errors. So just need help setting up these prototypes/structs/methods.
Thanks
05-15-2011 05:29 PM
Hi ngay528,
What errors are you seeing when you use that function? Would you mind posting some screen shots of what you are seeing?
Also, what header files are you including?
Regards,
Stephanie R.
National Instruments
05-16-2011 11:28 AM
Include Files:
Commenting out the include PortableDevice.h causes my program to compile, but have a feeling I need it to use the functions needed to enumerate.
05-18-2011 02:48 PM
Hello -
This actually turns out to be pretty tricky...
To use the API, you're going to need to do much of this manually, which can be a pretty tedious process - especially for an API this large. I got it started for you - but there is still much work left to do. I implemented some of the example code you listed above, and have attached it below. Note I did this pretty quickly, so it's a little rough and not very well commented, but hopefully you should be able to get the idea. You are likely going to need at least a rough idea of how COM works to be successful here. Most of what's in the main implementation file comes from the header files PortableDeviceApi.h and PortableDeviceTypes.h.
Take a look, run through the example, and if you're unable to figure out where some of what I did came from, feel free to ask.
NickB
National Instruments
05-20-2011 12:19 PM
Kudos.
That is very helpful and will look to expand the function list from it such as setguids and others.
Thanks