Click here to Skip to main content
12,688,944 members (32,247 online)
Click here to Skip to main content


278 bookmarked

Undocumented Visual C++

, 17 Sep 2000
Spelunking in the Badlands of MSDEV
// ---------------
// You may use, compile or redistribute this source as part of your application 
// for free. You may not redistribute it as a part of a software development 
// library without the agreement of the author. If the sources are 
// distributed along with the application, you should leave the original 
// copyright notes in the source code without any changes.
// This code can be used WITHOUT ANY WARRANTIES on your own risk.
// Nick Hodapp

// ExtensionAddinAW.cpp : implementation file

#include "stdafx.h"
#include "ExtensionAddin.h"
#include "ExtensionAddinAW.h"
#include "Chooser.h"

#import	"c:\Program Files\Microsoft Visual Studio\Common\MSDEV98\bin\ide\devbld.pkg"

#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

#include <rpcdce.h>

static GUID        Guid;

static const char *NewGuid()
   static char szGuid[38];
   unsigned char *pszGuid;
   UuidCreate( &Guid );
   if (RPC_S_OK != UuidToString( &Guid, &pszGuid ))
          return NULL;
   lstrcpyn(szGuid, (char *)pszGuid, sizeof(szGuid) );
   RpcStringFree( &pszGuid );
   return szGuid;

void CExtensionAddinAppWiz::InitCustomAppWiz()
	// Create a new dialog chooser; CDialogChooser's constructor initializes
	//  its internal array with pointers to the steps.
	m_pChooser = new CDialogChooser;

	// Set the maximum number of steps.

	// Add build step to .hpj if there is one
	m_Dictionary[_T("HELP")] = _T("1");

	// Inform AppWizard that we're making a DLL.
	m_Dictionary[_T("PROJTYPE_DLL")] = _T("1");

	// Set template macros based on the project name entered by the user.

	// Get value of $$root$$ (already set by AppWizard)
	CString strRoot;
	m_Dictionary.Lookup(_T("root"), strRoot);
	// Set value of $$Doc$$, $$DOC$$
	CString strDoc = strRoot.Left(6);
	m_Dictionary[_T("Doc")] = strDoc;
	m_Dictionary[_T("DOC")] = strDoc;

	// Set value of $$MAC_TYPE$$
	strRoot = strRoot.Left(4);
	int nLen = strRoot.GetLength();
	if (strRoot.GetLength() < 4)
		CString strPad(_T(' '), 4 - nLen);
		strRoot += strPad;
	m_Dictionary[_T("MAC_TYPE")] = strRoot;

	// generate clsid's:
	m_Dictionary[_T("TYPELIB_CLSID")] = NewGuid();

	m_Dictionary[_T("ICOMMANDS_CLSID")] = NewGuid();

	m_Dictionary[_T("COMMANDS_CLSID")] = NewGuid();

	m_Dictionary[_T("ADDIN_CLSID")] = NewGuid();

// This is called just before the custom AppWizard is unloaded.
void CExtensionAddinAppWiz::ExitCustomAppWiz()
	// Deallocate memory used for the dialog chooser
	ASSERT(m_pChooser != NULL);
	delete m_pChooser;
	m_pChooser = NULL;

// This is called when the user clicks "Create..." on the New Project dialog
//  or "Next" on one of the custom AppWizard's steps.
CAppWizStepDlg* CExtensionAddinAppWiz::Next(CAppWizStepDlg* pDlg)
	// Delegate to the dialog chooser
	return m_pChooser->Next(pDlg);

// This is called when the user clicks "Back" on one of the custom
//  AppWizard's steps.
CAppWizStepDlg* CExtensionAddinAppWiz::Back(CAppWizStepDlg* pDlg)
	// Delegate to the dialog chooser
	return m_pChooser->Back(pDlg);

void CExtensionAddinAppWiz::CustomizeProject(IBuildProject* pProject)
	using namespace DSProjectSystem;

   long lNumConfigs;
   IConfigurationsPtr pConfigs;
   IBuildProjectPtr pProj;
   // Needed to convert IBuildProject to the DSProjectSystem namespace
   pProj.Attach((DSProjectSystem::IBuildProject*)pProject, true);


   //Get each individual configuration
   for (long j = 1 ; j <= lNumConfigs ; j++)
      _bstr_t varTool;
      _bstr_t varSwitch;
      IConfigurationPtr pConfig;
      _variant_t varj = j;

      pConfig = pConfigs->Item(varj);

		// set for extension dll compilation
      varTool   = "cl.exe";
      varSwitch = "/D \"_AFXEXT\"";
		pConfig->AddToolSettings(varTool, varSwitch);
      varSwitch = "/D \"_USRDLL\"";
		pConfig->RemoveToolSettings(varTool, varSwitch, varj);

		CString strFile = m_Dictionary[_T("ROOT")];
		char szSettings[_MAX_PATH];

		_bstr_t varFile = strFile + ".idl";
		sprintf(szSettings, "/tlb \".\\%s.tlb\" /h \"%s.h\" /Oicf", (const char*)strFile, (const char*)strFile);
		varSwitch = szSettings;
		pConfig->AddFileSettings(varFile, varSwitch, varj);

// Here we define one instance of the CExtensionAddinAppWiz class.  You can access
//  m_Dictionary and any other public members of this class through the
//  global ExtensionAddinAW.
CExtensionAddinAppWiz ExtensionAddinAW;

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 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


About the Author

Nick Hodapp
Web Developer
United States United States
No Biography provided

You may also be interested in...

| Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170113.4 | Last Updated 18 Sep 2000
Article Copyright 2000 by Nick Hodapp
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid