Click here to Skip to main content
15,892,927 members
Articles / Desktop Programming / MFC

Using screensavers inside the Windows Media Player

Rate me:
Please Sign up or sign in to vote.
4.94/5 (12 votes)
15 Jul 2011CPOL1 min read 108.3K   3.1K   53  
Wrapping a screensaver inside a WMP visualization plug-in.
//------------------------------------------------------------------------------

#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "wmpplug.h"
#include "SheepWMP_h.h"
#include "SheepWMP_i.c"
#include "SheepWMP.h"

//------------------------------------------------------------------------------

CComModule _Module;

//------------------------------------------------------------------------------

BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_SheepWMP, CSheepWMP)
END_OBJECT_MAP()

//------------------------------------------------------------------------------

HINSTANCE gThisInstance = NULL ;

//------------------------------------------------------------------------------

extern "C"
BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
{
    if (dwReason == DLL_PROCESS_ATTACH)
    {
		gThisInstance = hInstance ;

        _Module.Init(ObjectMap, hInstance, &LIBID_SHEEPWMPLib);
        DisableThreadLibraryCalls(hInstance);
    }
    else if (dwReason == DLL_PROCESS_DETACH)
        _Module.Term();
    return TRUE;    // ok
}

//------------------------------------------------------------------------------

STDAPI DllCanUnloadNow(void)
{
    return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
}

//------------------------------------------------------------------------------

STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
    return _Module.GetClassObject(rclsid, riid, ppv);
}

//------------------------------------------------------------------------------

STDAPI DllRegisterServer(void)
{
    // registers object, typelib and all interfaces in typelib

    HRESULT hr = _Module.RegisterServer();

    // Notify WMP that plugin has been added

    WMPNotifyPluginAddRemove();

    return hr;
}

//------------------------------------------------------------------------------

STDAPI DllUnregisterServer(void)
{
    HRESULT hr = _Module.UnregisterServer();

    // Notify WMP that plugin has been removed

    WMPNotifyPluginAddRemove();

    return hr;
}

//------------------------------------------------------------------------------

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Web Developer
Australia Australia
Developing windows applications for over 15 years now starting on Win 3.1 with Object Oriented Pascal, progressed to C++ and OWL, in 1996 switch to MFC and never looked back, now focusing on .NET/Mono.

Comments and Discussions