Click here to Skip to main content
15,881,852 members
Articles / Desktop Programming / ATL

VS File Finder

Rate me:
Please Sign up or sign in to vote.
4.90/5 (39 votes)
8 May 20053 min read 222.7K   3.3K   37  
A Visual Studio add-in to help navigate around large projects.
// VSFileFinderCtrlApp.cpp : Implementation of CVSFileFinderCtrlApp and DLL registration.

#include "stdafx.h"
#include "VSFileFinderCtrlApp.h"
#include <initguid.h>
#include "VSFileFinderCtrl_i.c"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif



class CVSFileFinderCtrlModule :
	public CAtlMfcModule
{
public:
	DECLARE_LIBID(LIBID_VSFileFinderCtrlLib);
	DECLARE_REGISTRY_APPID_RESOURCEID(IDR_VSFILEFINDERCTRL, "{8FD04375-E091-434E-8BBE-EF6238337341}");};

CVSFileFinderCtrlModule _AtlModule;

CVSFileFinderCtrlApp NEAR theApp;

const GUID CDECL BASED_CODE _tlid =
		{ 0x20FCAA11, 0x72CE, 0x43ED, { 0x92, 0x3F, 0x66, 0x16, 0x46, 0x89, 0x3C, 0x6A } };
const WORD _wVerMajor = 1;
const WORD _wVerMinor = 0;



// CVSFileFinderCtrlApp::InitInstance - DLL initialization

BOOL CVSFileFinderCtrlApp::InitInstance()
{
	BOOL bInit = COleControlModule::InitInstance();

	if (bInit)
	{
		// TODO: Add your own module initialization code here.
	}

	return bInit;
}



// CVSFileFinderCtrlApp::ExitInstance - DLL termination

int CVSFileFinderCtrlApp::ExitInstance()
{
	// TODO: Add your own module termination code here.

	return COleControlModule::ExitInstance();
}



// DllRegisterServer - Adds entries to the system registry

STDAPI DllRegisterServer(void)
{
	_AtlModule.UpdateRegistryAppId(TRUE);
	HRESULT hRes = _AtlModule.RegisterServer(TRUE);
	if (hRes != S_OK)
		return hRes;
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleRegisterTypeLib(AfxGetInstanceHandle(), _tlid))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(TRUE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}



// DllUnregisterServer - Removes entries from the system registry

STDAPI DllUnregisterServer(void)
{
	_AtlModule.UpdateRegistryAppId(FALSE);
	HRESULT hRes = _AtlModule.UnregisterServer(TRUE);
	if (hRes != S_OK)
		return hRes;
	AFX_MANAGE_STATE(_afxModuleAddrThis);

	if (!AfxOleUnregisterTypeLib(_tlid, _wVerMajor, _wVerMinor))
		return ResultFromScode(SELFREG_E_TYPELIB);

	if (!COleObjectFactoryEx::UpdateRegistryAll(FALSE))
		return ResultFromScode(SELFREG_E_CLASS);

	return NOERROR;
}

// DllCanUnloadNow - Allows COM to unload DLL
#pragma comment(linker, "/EXPORT:DllCanUnloadNow=_DllCanUnloadNow@0,PRIVATE")
#pragma comment(linker, "/EXPORT:DllGetClassObject=_DllGetClassObject@12,PRIVATE")
#pragma comment(linker, "/EXPORT:DllRegisterServer=_DllRegisterServer@0,PRIVATE")
#pragma comment(linker, "/EXPORT:DllUnregisterServer=_DllUnregisterServer@0,PRIVATE")

STDAPI DllCanUnloadNow(void)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if (_AtlModule.GetLockCount() > 0)
		return S_FALSE;
	return S_OK;
}

// DllGetClassObject - Returns class factory
STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
{
	AFX_MANAGE_STATE(AfxGetStaticModuleState());
	if (S_OK == _AtlModule.GetClassObject(rclsid, riid, ppv))
		return S_OK;
	return AfxDllGetClassObject(rclsid, riid, ppv);
}

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 has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions