none
WPD Api Sample failing to return Device Count

    Question

  • Hi Experts,

    I am having an issue with the WPD Api sample provided with Windows Vista SDK and I am running the application in Windows XP.

    I am trying to identify a WIA device via the IPortableDeviceManager interface. I tried with IWIADeviceManager interface earlier but switched to the former since thumbnail full path method calls were not returning proper results.

    I could compile the WPD Api Sample workspace and could successfully register the Interface, IPortableDeviceManager interface, but the same returns 0 devices when i call:

    hr = pPortableDeviceManager->GetDevices(NULL, &cPnPDeviceIDs);

    I have connected the camera in PTP mode and not in USB mode. Any ideas or hints on why this is happening? Or is there any other restriction on the devices.

    I have not yet installed .Net Frame Work 3, but i dont think it is the problem.

    All feedbacks are most welcome.

    Rosh K. Mathews.

    Tuesday, January 02, 2007 12:49 PM

All replies

  • One more update from my side. I have installed .netframework3 and still WPD interface is not functioning in XP.

    Is there something else that is required for the same to work.

    It would also be helpful if it was clear whether WPD is the under lying layer, because in one MSDN page it is mentioned that WIA interacts with WPD which in turn communicates with the device. In another page, it was mentioned that WPD is superseding the WIA and WMDM interfaces.

    Thanks a lot in advance,

    Rosh K. Mathews.

    Friday, January 05, 2007 4:37 AM
  • Hi Rosh,

    On Windows XP, WIA devices do not enumerate under WPD as this support is only added in Windows Vista.    On Windows Vista, WPD is the underlying layer for WIA (camera devices only) and WMDM.

    Hope this helps,

    Lisa

    Tuesday, January 23, 2007 2:28 AM
  • Hi Lisa,

    Thanks for the update. So you mean to say that WIA is the underlaying in XP and WPD is the underlying layer from Vista onwards. Hope i am right.

    I have one more question though. In Vista, using WIA i can get thumbnail of an image but using WPD i cannot. I checked out thumbnail generation in the sample application for WPD provided (WPDApiSample). It is not demonstrating the same.

    If WPD is the underlying layer and if WIA is able to do it, then WPD should have it implemented. Can u help me with this?

     

    Thanks a lot for replying,

    Rosh K. Mathews.

    Wednesday, January 24, 2007 6:19 AM
  • Rosh,

     

    I too am doing WIA on XP and WPD on Vista. Can you tell me how (Code snip?) you got thumbnails in WIA? I can get filename, but cannot get Thumnail data into correct image format (DIB or bitmap, etc) to display in a form.

     

    Thanks,

    VJ

    Friday, February 23, 2007 9:43 PM
  • Hi
    I am using Windows driver kit and visual studio 2005.I have to show the portable audio players connected to the PC in windows media player11.How can i do it?
    we have got the samples when installing Windows driver kit.The sample(WpdHelloWorldDriver and WpdWudfDriver) are behaving as an Virtual Hardware Device.I need to take these sample as an base template and do modifications.Can anyone tell me how can i enumerate the devices in the media player 11
    please please anybody help me.I am working on it past a week but couldnt do it as i am new bibe to wdk.

    Thanks

    vinnu

    Wednesday, April 04, 2007 12:33 PM
  • The wpdwudfsample driver can be modified to appear in WMP11 as described below:

    http://blogs.msdn.com/wpdblog/archive/2007/05/08/getting-a-wpd-sample-driver-working-with-windows-media-player-11.aspx


    Sunday, May 13, 2007 2:27 AM
  • Microsoft claim that WPD and MTP are supported on XP with WMP11 installed, and indeed this is the case!

    However by default on XP a camera device will most likely load the PTP driver stack instead. You can check this by looking at the Driver Details page from Device Manager, Properties, Driver tab, where you should see:

    • C:\Windows\System32\ptpusb.dll
    • C:\Windows\System32\ptpusd.dll

    That is, unless your camera vendor has thoughtfully supplied a custom WPD compatible INF file for your device on XP. Most haven't, probably due to the reliance on WMP10/11.

    However it is relatively easy to create your own custom INF to enable MTP, and details for this are given in the Microsoft Media Transfer Protocol Porting Kit in the mtpdev.chm help file under section "Providing a Custom INF File for an MTP Device".

    However the detail there seem somewhat incomplete, and there is further information to be had about the sections required in the comments of C:\Windows\Inf\WpdMtp.inf installed with Windows Media Player 11:

    ;;******************************************************************************
    ;; The following are to be used in vendor specific "Includes" and "Needs" sections.
    ;; Specifically, the INF should contain:
    ;;
    ;; [DDInstall]
    ;; Include = wpdmtp.inf
    ;; Needs  = WPD.MTP
    ;;
    ;; [DDInstall.hw]
    ;; Include = wpdmtp.inf
    ;; Needs  = WPD.MTP.Registration    <- includes all default legacy API and autoplay registration for the device
    ;; - OR - 
    ;; Needs  = WPD.MTP.RegistrationBasic <- only do minimum registration, no legacy API or autoplay
    ;;
    ;; [DDInstall.Services]
    ;; Include = wpdmtp.inf
    ;; Needs  = WPD.MTP.Services
    ;;
    ;; [DDInstall.CoInstallers]
    ;; Include = wpdmtp.inf
    ;; Needs = WPD.MTP.CoInstallers
    ;;
    ;; [DDInstall.Wdf]
    ;; Include = wpdmtp.inf
    ;; Needs = WPD.MTP.Wdf
    ;; UmdfServiceOrder=WpdMtpDriver
    ;;
    ;;******************************************************************************
    

    For example, for a Nikon D90, the following INF file can be created:

    [Version]
    Signature="$WINDOWS NT$"
    Class=WPD
    ClassGUID={EEC5AD98-8080-425f-922A-DABF3DE3F69A}
    Provider=%Provider%
    DriverVer=02/22/2006,5.2.5326.4762
    
    [Manufacturer]
    %MfgName%=Nikon
    
    [Nikon]
    %Nikon.DeviceDesc%=Nikon_MTP, USB\VID_04B0&PID_0421
    
    [Nikon_MTP]
    Include = wpdmtp.inf
    Needs  = WPD.MTP
    
    [Nikon_MTP.hw]
    Include = wpdmtp.inf
    Needs  = WPD.MTP.RegistrationBasic
    
    [Nikon_MTP.Services]
    Include = wpdmtp.inf
    Needs  = WPD.MTP.Services
    
    [Nikon_MTP.CoInstallers]
    Include = wpdmtp.inf
    Needs  = WPD.MTP.CoInstallers
    
    [Nikon_MTP.Wdf]
    Include = wpdmtp.inf
    Needs  = WPD.MTP.Wdf
    UmdfServiceOrder=WpdMtpDriver
    
    [Strings]
    Nikon.DeviceDesc    = "Nikon D90 MTP Device"
    MfgName         = "Nikon"
    Provider        = "Nikon"
    

    To support different devices change, or add additional items, under the [Nikon] section with the correct PID and VID for your device. You can find these in Device Manager on the Details tab by selecting "Hadrware Ids" from the drop down. You'll probably also want to change all the references to "Nikon" if your camera is from a different manufacturer.

    Once you have created your INF file in notepad, save under an appropriate name, for example NikonD90.INF. Then:

    • In Windows Device Manager right click the camera device and "Update Driver".
    • Select "No, not this time" when Windows asks to search Windows Update.
    • Select "Install from a list or specific location (Advanced)".
    • Select "Don't search, I will choose the drive to install".
    • Click "Have Disk".
    • Click "Browser" and navigate to the folder where you saved the INF file created above.
    • Select the INF file and it should install the MTP drivers.

    Now in Device manager you should see that the camera device has moved from "Imaging Devices" and is now displayed under "Portable Devices" instead. Also on the driver details you should see the following files indicating that the generic WPD MTP class drivers are being used (instead of PTP previously):

    • C:\Windows\System32\wpdusb.dll
    • C:\Windows\System32\wudfrd.dll

    You should now be able to successfully enumerate your MTP device using IPortableDeviceManager.GetDevices and use all of the other API functions to send custom MTP commands. See the MSDN posts by dimeby8 for details.

    The above solution allows you to build applications with a common API that work on Windows XP through Windows 7 in either 32 or 64 bit with no code changes.

    • Edited by pcbbc Tuesday, February 15, 2011 10:40 AM Formatting
    Tuesday, February 15, 2011 10:37 AM