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.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.