Modifying Wizard-generated Code

[The feature associated with this page, Windows Media Player SDK, is a legacy feature. It has been superseded by MediaPlayer. MediaPlayer has been optimized for Windows 10 and Windows 11. Microsoft strongly recommends that new code use MediaPlayer instead of Windows Media Player SDK, when possible. Microsoft suggests that existing code that uses the legacy APIs be rewritten to use the new APIs if possible.]

There are several places in the wizard-generated plug-in code that you must modify before your plug-in will work with Windows Media Player 10 Mobile. The code you must modify is bold in the following examples.

Changes to wmpplug.h

ANSI methods are not supported on devices running Windows CE, so you must modify the following ANSI method generated by the wizard in wmpplug.h:

return( ::PostMessage( HWND_BROADCAST, ::RegisterWindowMessageA( "WMPlayer_PluginAddRemove" ), 0, 0 ) );

Modify it as shown in the following so that it becomes a Unicode method:

return( ::PostMessage( HWND_BROADCAST, ::RegisterWindowMessageW( L"WMPlayer_PluginAddRemove" ), 0, 0 ) );

Changes to NetworkPlugin.h

Find the following code in NetworkPlugin.h:

BEGIN_COM_MAP(CNetworkPlugin)
    COM_INTERFACE(IWMPPluginUI)
END_COM_MAP()

Modify the code so that it looks like this:

BEGIN_COM_MAP(CNetworkPlugin)
    
COM_INTERFACE_ENTRY_IID(__uuidof(IWMPPluginUI), IWMPPluginUI)
END_COM_MAP()

Changes to NetworkPlugindll.cpp

Find the DllMain function in NetworkPlugindll.cpp:

extern "C" BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, hInstance);
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();
    return TRUE;    // ok
}

Modify the code so that it looks like this:

extern "C" BOOL WINAPI DllMain(HANDLE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
        _Module.Init(ObjectMap, (HINSTANCE)hInstance);
#ifndef UNDER_CE
        DisableThreadLibraryCalls((HINSTANCE)hInstance);
#endif
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();
    return TRUE;    // ok
}

Changes to NetworkPlugin.cpp

Find the following code in NetworkPlugin.cpp:

hr = m_spCore->QueryInterface(&spConnectionContainer);

Modify the code so that it looks like this:

hr = m_spCore->QueryInterface(__uuidof(IConnectionPointContainer), (void**)&spConnectionContainer);

Change the Threading Model

Unlike ATL for Windows, ATL for Windows CE does not support the apartment threading model because the apartment model requires more memory resources than the single threading and free threading models. Therefore, you must find all instances of apartment threading in StdAfx.h and NetworkPlugin.rgs and change them to indicate free threading.

Also, you can only call the Windows Media Player 10 Mobile control from the thread on which it was created.

Build and Test the Project

After making these changes outlined here, you can build your project to verify that it compiles before you add any custom code.

  1. Set the active project configuration to Win32 (WCE ARMV4) Debug or Win32 (WCE ARMV4) Release.
  2. Set the active platform to Pocket PC 2003.
  3. Click the Build menu item, and then select Build NetworkPlugin.dll. It should compile, download, and register itself on your device.

Creating a User Interface Plug-in for Windows Media Player 10 Mobile