Click here to Skip to main content
15,896,063 members
Articles / Desktop Programming / WTL

Windows Media Player Standby Plug-in

Rate me:
Please Sign up or sign in to vote.
4.47/5 (13 votes)
27 May 2005CPOL4 min read 209.4K   7.9K   32  
Media Player plug-in turning computer off when media ends
In this article, you will see my implementation which is similar to the TV's Sleep timer function. You will also see my Media Player plug-in which instead of turning Media Player off after the specified interval of time turns the PC off when the media ends.
/////////////////////////////////////////////////////////////////////////////
// #ifndef __ARMEN_H__
// #define __ARMEN_H__//     
//	   Armen Hakobyan, 2005.
//	   http://www.codeproject.com/script/articles/list_articles.asp?userid=25653
// #endif // __ARMEN_H__
/////////////////////////////////////////////////////////////////////////////

#include "stdafx.h"

#include <initguid.h>
#include "plugins.h"

/////////////////////////////////////////////////////////////////////////////

CComModule	_Module;

BEGIN_OBJECT_MAP( ObjectMap )
	OBJECT_ENTRY( CLSID_UiPlugin, CUiPlugin )
	OBJECT_ENTRY( CLSID_BkPlugin, CBkPlugin )
END_OBJECT_MAP()

/////////////////////////////////////////////////////////////////////////////
// DLL Entry Point

EXTERN_C BOOL WINAPI DllMain( IN HINSTANCE	hInstance, 
							  IN DWORD		dwReason, 
							  IN LPVOID		/*lpReserved*/ )
{
    switch( dwReason )
	{
	case DLL_PROCESS_ATTACH:
		{
			_Module.Init( ObjectMap, hInstance );
			DisableThreadLibraryCalls( hInstance );			
		}
		break;
    case DLL_PROCESS_DETACH:
		{
			_Module.Term();
		}
		break;
	};

    return TRUE;    // ok
}

/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE

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

/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type

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

/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer( VOID )
{
	// Check for w2k/me or later

	if( AtlIsOldWindows() )
		return CO_E_WRONGOSFORAPP;

    // Register object, typelib and all interfaces in typelib

    HRESULT hr = _Module.RegisterServer();

    // Notify WMP that plugin has been added

    WMPNotifyPluginAddRemove();

    return hr;
}

/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry

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
Software Developer (Senior) SafeNet Inc
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions