Click here to Skip to main content
Click here to Skip to main content
Add your own
alternative version

Win32 Simple Application AppWizard

, 22 Jun 2004
An article on creating an AppWizard to create Win32 based applications.
// SimpleApplicationWizardaw.cpp : implementation file

#include "stdafx.h"
#include "SimpleApplicationWizard.h"
#include "SimpleApplicationWizardaw.h"
#include "chooser.h"

#undef THIS_FILE
static char THIS_FILE[] = __FILE__;

// This is called immediately after the custom AppWizard is loaded.  Initialize
//  the state of the custom AppWizard here.
void CSimpleApplicationWizardAppWiz::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.

	// TODO: Add any other custom AppWizard-wide initialization here.

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

	// TODO: Add code here to deallocate resources used by the custom AppWizard

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

void CSimpleApplicationWizardAppWiz::CustomizeProject(IBuildProject* pProject)
	CComPtr<IConfigurations> pConfigs;
	HRESULT hr=pProject->get_Configurations(&pConfigs);
		AfxMessageBox("An error occurred while obtaining the IConfigurations interface pointer");
	CComPtr<IConfiguration> pConfig;
	CComVariant index;
	VARIANT dummy = {0};
	CComBSTR Name;
	CString text;
	CString output;

	long Count=0;

	// Iterate through all the configurations of the project
	for(int i=1; i <= Count; i++)
		hr=pConfigs->Item(index, &pConfig);
			AfxMessageBox("An error occurred while obtaining the IConfiguration pointer");
		text = Name;
		if (text.Find("Debug") == -1)
			output = "Release";
			output = "Debug";

		pConfig->AddToolSettings(L"link.exe", text.AllocSysString(), dummy);
		pConfig->AddToolSettings(L"mfc", L"0", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/subsystem:windows", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/incremental:yes", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/machine:I386", dummy);
		pConfig->AddToolSettings(L"link.exe", L"/nodefaultlib:\"MSVCRTD\"", dummy);

		// change the preprocessor definitions
		pConfig->AddToolSettings(L"cl.exe", L"/D \"_WINDOWS\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/nologo", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/D \"_MBCS\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/D \"WIN32\"", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/Od", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/MD", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/W3", dummy);
		pConfig->AddToolSettings(L"cl.exe", L"/ZI", dummy);	// Program Database for "Edit & Continue" can not be defined when /driver option is defined
		pConfig->AddToolSettings(L"cl.exe", L"/GZ", dummy);	//GZ initializes all local variables not explicitly initialized by the program. It fills all memory used by these variables with 0xCC
		pConfig->AddToolSettings(L"cl.exe", L"/Zi", dummy);	// Program Database
		pConfig->AddToolSettings(L"cl.exe", L"/Oi", dummy);	// 
		pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy);	// __stdcall calling convention
		pConfig->AddToolSettings(L"cl.exe", L"/Gz", dummy);

		// Change the libraries
		pConfig->AddToolSettings(L"link.exe", L"kernel32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"user32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"gdi32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"winspool.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"comdlg32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"advapi32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"shell32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"ole32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"oleaut32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"uuid.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"odbc32.lib", dummy);
		pConfig->AddToolSettings(L"link.exe", L"odbccp32.lib", dummy);
		CString cstr;
			pConfig->AddToolSettings(L"link.exe", L"comctl32.lib", dummy);

			pConfig->AddToolSettings(L"link.exe", L"ws2_32.lib", dummy);


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

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

Fabio Fornaro
Software Developer (Senior)
Italy Italy
Worked as a Java developer targeting J2EE and J2SE for half a decade.
Now he's employed for Avanade as a Senior Associate Consultant on Microsoft technologies.
His hobbies are Win32 programming using SDK, MFC, ATL and COM; playing guitar and listening to music.

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.150327.1 | Last Updated 23 Jun 2004
Article Copyright 2004 by Fabio Fornaro
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid