MTP Device Serial Numbers on Windows

MTP Device Serial Numbers on Windows


Introduction:

This brief tutorial will detail how to retrieve serial numbers from MTP devices. MTP Serial numbers are not guaranteed to be retrievable, but if one can be retrieved, the number should be unique.

Retrieving the serial number is accomplished with a single call -- IWMDMDevice::GetSerialNumber. This call supports message authentication if desired (the sample code doesn't authenticate the returned serial number).

Instructions:

1) Download the Windows Media Format 9.5 SDK, which includes the Windows Media Device Manager 10 SDK. The SDK should be available at http://msdn.microsoft.com/windowsmedia/downloads/default.aspx (wmformat95sdk.exe).

2) Install the SDK.

3) Add the new lib and include directories (by default, c:\wmsdk\wmfsdk95\include, c:\wmsdk\wmfsdk95\wmdm\inc, c:\wmsdk\wmfsdk95\lib, and c:\wmsdk\wmfsdk95\wmdm\lib) into your IDE. For VS2005, this is done by selecting the panel at Tools..Options..Projects&Solutions..VC++ Directories. Other Microsoft development environments are similar.

4) Create a new 32-bit C++ command-line application template and test to make sure it compiles and links properly.

5) Replace the template code with this code.

8) Add the library "mssachlp.lib" to the debug and release build linker input library settings.

9) Build the revised project and run it.