|
//////////////////////////////////////////////////////////////////////
//
// This utility written and copyright by Michael Dunn (mdunn at inreach
// dot com). You may freely use and redistribute this source code and
// binary as long as this notice is retained.
//
// Contact me if you have any questions, comments, or bug reports. Get
// the latest updates at http://home.inreach.com/mdunn/code/
//
//////////////////////////////////////////////////////////////////////
//
// Revision history:
// Feb 28, 2000: Version 1.0: First release.
//
// June 5, 2000: Version 1.1: Fixed (un)registration so the DLL works
// on NT/2000.
//
// Oct 28, 2001: Version 1.1.1: Added 4 default wildcards, *.ncb, *.aps,
// *.bsc, *.sbr.
//
//////////////////////////////////////////////////////////////////////
// DirClean.cpp : Implementation of DLL Exports.
// Note: Proxy/Stub Information
// To build a separate proxy/stub DLL,
// run nmake -f DirCleanps.mk in the project directory.
#include "stdafx.h"
#include "resource.h"
#include <initguid.h>
#include "DirClean.h"
#include "DirClean_i.c"
#include "DirCleanShlExt.h"
CComModule _Module;
BEGIN_OBJECT_MAP(ObjectMap)
OBJECT_ENTRY(CLSID_DirCleanShlExt, CDirCleanShlExt)
END_OBJECT_MAP()
class CDirCleanApp : public CWinApp
{
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CDirCleanApp)
public:
virtual BOOL InitInstance();
virtual int ExitInstance();
//}}AFX_VIRTUAL
//{{AFX_MSG(CDirCleanApp)
// NOTE - the ClassWizard will add and remove member functions here.
// DO NOT EDIT what you see in these blocks of generated code !
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
BEGIN_MESSAGE_MAP(CDirCleanApp, CWinApp)
//{{AFX_MSG_MAP(CDirCleanApp)
// NOTE - the ClassWizard will add and remove mapping macros here.
// DO NOT EDIT what you see in these blocks of generated code!
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
CDirCleanApp theApp;
BOOL CDirCleanApp::InitInstance()
{
_Module.Init(ObjectMap, m_hInstance, &LIBID_DIRCLEANLib);
SetRegistryKey ( _T("Mike's Classy Software") );
return CWinApp::InitInstance();
}
int CDirCleanApp::ExitInstance()
{
_Module.Term();
return CWinApp::ExitInstance();
}
/////////////////////////////////////////////////////////////////////////////
// Used to determine whether the DLL can be unloaded by OLE
STDAPI DllCanUnloadNow(void)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
return (AfxDllCanUnloadNow()==S_OK && _Module.GetLockCount()==0) ? S_OK : S_FALSE;
}
/////////////////////////////////////////////////////////////////////////////
// Returns a class factory to create an object of the requested type
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
return _Module.GetClassObject(rclsid, riid, ppv);
}
/////////////////////////////////////////////////////////////////////////////
// DllRegisterServer - Adds entries to the system registry
STDAPI DllRegisterServer(void)
{
// Add ourself to the approved extensions list on NT.
if ( 0 == (GetVersion() & 0x80000000) )
{
CRegKey reg;
LONG lRet;
lRet = reg.Open ( HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
KEY_SET_VALUE );
if ( ERROR_SUCCESS != lRet )
return E_ACCESSDENIED;
lRet = reg.SetValue ( _T("DirClean Shell Extension"),
_T("{BA06A5A0-BDE3-11D3-BE82-0050DA63C294}") );
if ( ERROR_SUCCESS != lRet )
return E_ACCESSDENIED;
}
// registers object, typelib and all interfaces in typelib
return _Module.RegisterServer(TRUE);
}
/////////////////////////////////////////////////////////////////////////////
// DllUnregisterServer - Removes entries from the system registry
STDAPI DllUnregisterServer(void)
{
// Remove ourself from the approved extensions list on NT.
if ( 0 == (GetVersion() & 0x80000000) )
{
CRegKey reg;
LONG lRet;
lRet = reg.Open ( HKEY_LOCAL_MACHINE,
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Shell Extensions\\Approved"),
KEY_SET_VALUE );
if ( ERROR_SUCCESS == lRet )
{
reg.DeleteValue ( _T("{BA06A5A0-BDE3-11D3-BE82-0050DA63C294}") );
reg.Close();
}
}
return _Module.UnregisterServer(TRUE);
}
|
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.
Michael lives in sunny Mountain View, California. He started programming with an Apple
//e in 4th grade, graduated from
UCLA with a math degree in 1994, and immediately landed a job as a QA engineer at Symantec, working on the Norton AntiVirus team. He pretty much taught himself Windows and MFC programming, and in 1999 he designed and coded a new interface for Norton AntiVirus 2000.
Mike has been a a developer at
Napster and at his own lil' startup, Zabersoft, a development company he co-founded with offices in Los Angeles and Odense, Denmark. Mike is now a senior engineer at
VMware.
He also enjoys his hobbies of playing pinball, bike riding, photography, and Domion on Friday nights (current favorite combo: Village + double Pirate Ship). He would get his own snooker table too if they weren't so darn big! He is also sad that he's forgotten the languages he's studied: French, Mandarin Chinese, and Japanese.
Mike was a
VC MVP from 2005 to 2009.