|
#include <atlbase.h>
extern CComModule _Module;
#include <atlcom.h>
#include <initguid.h>
#include <ObjModel\bldauto.h>
#include <ObjModel\bldguid.h>
void CREQAppWiz::CustomizeProject(IBuildProject* pProject)
{
CComPtr<IConfigurations> spConfigs;
HRESULT hr=pProject->get_Configurations(&spConfigs);
if(FAILED(hr))
{
AfxMessageBox("An error occurred while obtaining "
"the IConfigurations interface pointer");
return;
}
long Count=0;
spConfigs->get_Count(&Count);
if(Count == 0)
{
AfxMessageBox("There are no configurations to customize");
return;
}
CComPtr<IConfiguration> spConfig;
CComBSTR tool_name=L"mfc"; //MFC tool
CComBSTR tool_settings="0";
//None : 0, Static Libraries : 1, Shared Dll : 2
CComVariant index;
VARIANT dummy; //reserved
for(int i=1; i <= Count; i++)
{
index=i;
hr=spConfigs->Item(index, &spConfig);
if(FAILED(hr))
{
AfxMessageBox("An error occurred while obtaining "
"the IConfiguration pointer");
return;
}
hr=spConfig->AddToolSettings(tool_name, tool_settings, dummy);
if(FAILED(hr))
{
AfxMessageBox("Failed to change to MFC static libraries");
return;
}
spConfig=NULL;
}
spConfigs=NULL;
ATLTRACE("Operation completed successfully");
}
| |