home *** CD-ROM | disk | FTP | other *** search
- // RegenWizardaw.cpp : implementation file
- //
-
- #include "stdafx.h"
- #include "RegenWizard.h"
- #include "RegenWizardaw.h"
-
-
- #ifdef _PSEUDO_DEBUG
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
-
- CRegenWizardAppWiz::CRegenWizardAppWiz() :
- CCustomAppWiz(),
- m_strRegistryKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\App Paths\\"),
- m_clsFirstStep(this),
- m_clsSecondStep(this),
- m_clsRegenProps(this),
- m_clsEvents(this),
- m_clsFilterInfo(this),
- m_clsToolBasicInfo(this)
- {
- }
-
- bool CRegenWizardAppWiz::Try(CString strCADName)
- {
- unsigned char *str = new unsigned char[255];
- unsigned long ulTmp,
- ulLength = 255;
- HKEY hKey = 0;
- CString strPath;
-
- RegOpenKeyEx(HKEY_LOCAL_MACHINE, m_strRegistryKey + strCADName, 0, KEY_EXECUTE, &hKey);
- if (!hKey) return false;
-
- RegQueryValueEx(hKey, "Path", NULL, &ulTmp, str, &ulLength);
-
- strPath = str;
- strPath = strPath.Left(strPath.GetLength() - 8);
-
- m_strTCW = strPath + (CString)"Program\\";
- m_strSDKInclude = strPath + (CString)"SDK\\Include\\";
- m_strDestination = strPath + (CString)"Program\\Regens";
-
- m_clsSecondStep.m_strDestination = m_strDestination;
- m_clsSecondStep.m_strSDKInclude = m_strSDKInclude;
-
- delete[] str;
- return true;
- }
-
- void CRegenWizardAppWiz::CreatePathVariables()
- {
- if (Try("Tcw70.Exe")) return;
- if (Try("Tcw80.Exe")) return;
- if (Try("Tcw90.Exe")) return;
- if (Try("Tcw10.Exe")) return;
- if (Try("Tcw11.Exe")) return;
- }
-
-
- void CRegenWizardAppWiz::FillDictionary()
- {
- CString cstrStdAfxUUID = GenGUID();
- cstrStdAfxUUID.Replace("-","_");
-
- m_Dictionary[_T("Project_TypeLibrary_GUID")] = GenGUID();
- m_Dictionary[_T("Regen_COClass_GUID")] = GenGUID();
- m_Dictionary[_T("Regen_Interface_GUID")] = GenGUID();
-
- m_Dictionary[_T("STD_AFX_GUID")] = cstrStdAfxUUID;
-
- m_Dictionary[_T("SDKIncludeDirectory")] = m_strSDKInclude;
-
- m_Dictionary[_T("CREATEEVENTSMASK.CPP")] = _T("CREATEEVENTSMASK.CPP");
-
- m_Dictionary[_T("ALLEVENTS.IDL")] = _T("EVENTS.IDL");
- m_Dictionary[_T("ALLEVENTS.CPP")] = _T("EVENTS.CPP");
- m_Dictionary[_T("ALLEVENTS.H")] = _T("EVENTS.H");
-
- m_Dictionary[_T("REGEN.IDL")] = _T("REGEN.IDL");
- m_Dictionary[_T("REGEN.CPP")] = _T("REGEN.CPP");
- m_Dictionary[_T("REGEN.H")] = _T("REGEN.H");
-
- m_Dictionary[_T("TOOL.IDL")] = _T("TOOL.IDL");
- m_Dictionary[_T("TOOL.CPP")] = _T("TOOL.CPP");
- m_Dictionary[_T("TOOL.H")] = _T("TOOL.H");
-
- m_Dictionary[_T("FILTER.IDL")] = _T("FILTER.IDL");
- m_Dictionary[_T("FILTER.CPP")] = _T("FILTER.CPP");
- m_Dictionary[_T("FILTER.H")] = _T("FILTER.H");
-
- m_Dictionary[_T("TIE.IDL")] = _T("TIE.IDL");
- m_Dictionary[_T("TIE.CPP")] = _T("TIE.CPP");
- m_Dictionary[_T("TIE.H")] = _T("TIE.H");
- }
-
- // This is called immediately after the custom AppWizard is loaded. Initialize
- // the state of the custom AppWizard here.
- void CRegenWizardAppWiz::InitCustomAppWiz()
- {
- // There are no steps in this custom AppWizard.
- SetNumberOfSteps(4);
-
- // 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");
-
- m_iDlgNumber = 0;
-
- CreatePathVariables();
- FillDictionary();
- }
-
- // This is called just before the custom AppWizard is unloaded.
- void CRegenWizardAppWiz::ExitCustomAppWiz()
- {
- // TODO: Add code here to deallocate resources used by the custom AppWizard
- }
-
- CAppWizStepDlg* CRegenWizardAppWiz::RetDialog()
- {
- switch (m_iDlgNumber)
- {
- case 1: return &m_clsFirstStep;
- case 2:
- {
- m_clsSecondStep.m_strDestination = m_strDestination;
- return &m_clsSecondStep;
- };
- case 3: return &m_clsEvents;
- case 4:
- {
- if (m_Dictionary [_T("RegenCreating")] == _T("Yes"))
- return &m_clsRegenProps;
- if (m_Dictionary [_T("ToolCreating")] == _T("Yes"))
- return &m_clsToolBasicInfo;
- if (m_Dictionary [_T("FilterCreating")] == _T("Yes"))
- return &m_clsFilterInfo;
- if (m_Dictionary [_T("TieCreating")] == _T("Yes"))
- return NULL;
- };
- default: return NULL;
- };
- }
-
-
- CAppWizStepDlg* CRegenWizardAppWiz::Back(CAppWizStepDlg* pDlg)
- {
- m_iDlgNumber--;
-
- return RetDialog();
- }
-
- CAppWizStepDlg* CRegenWizardAppWiz::Next(CAppWizStepDlg* pDlg)
- {
- m_iDlgNumber++;
-
- return RetDialog();
- }
-
- BSTR MakeBSTR(CString str)
- {
- return str.AllocSysString();
- }
-
- BSTR MakeBSTR(const char* str)
- {
- CString cstr = str;
- return MakeBSTR(cstr);
- }
-
- void CRegenWizardAppWiz::ChangeToolSettings(IConfiguration *pConfig, const char* strToolName, const char* strSetting, bool boolAdd)
- {
- BSTR bstrName = MakeBSTR (strToolName);
- BSTR bstrSetting = MakeBSTR (strSetting);
-
- if (boolAdd)
- pConfig->AddToolSettings(bstrName, bstrSetting, varMissed);
- else
- pConfig->RemoveToolSettings(bstrName, bstrSetting, varMissed);
-
- ::SysFreeString (bstrName);
- ::SysFreeString (bstrSetting);
- }
-
-
- void CRegenWizardAppWiz::ProcessConfig(IConfiguration *pConfig)
- {
- ChangeToolSettings(pConfig, "midl.exe", "/mktyplib203", false);
- ChangeToolSettings(pConfig, "midl.exe", (CString)"/I\"" + m_strSDKInclude + "\"", true);
-
- ChangeToolSettings(pConfig, "cl.exe", (CString)"/I\"" + m_strSDKInclude + "\"", true);
-
- ChangeToolSettings(pConfig, "link.exe", (CString)"/out:\"" + m_strDestination+
- (CString)"/" + m_strRoot+(CString)".dll\"", true);
- ChangeToolSettings(pConfig, "rc.exe", (CString)"/i\"" + m_strSDKInclude + "\"", true);
- }
-
- void CRegenWizardAppWiz::SomethingWasByDefault()
- {
- m_Dictionary.Lookup(_T("root"), m_strRoot);
-
- // Set value of $$Doc$$, $$DOC$$
- CString strDoc = m_strRoot.Left(6);
- m_Dictionary[_T("Doc")] = strDoc;
- strDoc.MakeUpper();
- m_Dictionary[_T("DOC")] = strDoc;
-
- // Set value of $$MAC_TYPE$$
- CString strTmp = m_strRoot.Left(4);
- int nLen = strTmp.GetLength();
- if (strTmp.GetLength() < 4)
- {
- CString strPad(_T(' '), 4 - nLen);
- strTmp += strPad;
- }
- strTmp.MakeUpper();
- m_Dictionary[_T("MAC_TYPE")] = strTmp;
- }
-
- CString CRegenWizardAppWiz::GenGUID()
- {
- UUID uuid;
- unsigned char *strUUID = NULL;
- CString strResult;
-
- UuidCreate(&uuid);
- UuidToString(&uuid, &strUUID);
-
- strResult = strUUID;
- strResult.MakeUpper();
-
- RpcStringFree(&strUUID);
-
- return strResult;
- }
-
- void CRegenWizardAppWiz::CustomizeProject(IBuildProject* pProject)
- {
- SomethingWasByDefault();
-
- HRESULT hRes = S_OK;
- IConfigurations *pConfigs = NULL;
- IConfiguration *pConfig = NULL;
- IEnumVARIANT *pEachEnum = NULL;
- VARIANT varPointer;
-
- varPointer.vt = VT_EMPTY;
- try
- {
- hRes = pProject->get_Configurations(&pConfigs);
- CHECK_HRESULT(hRes);
-
- hRes = pConfigs->get__NewEnum((IUnknown**)&pEachEnum);
- CHECK_HRESULT(hRes);
-
- while (pEachEnum->Next(1, &varPointer, NULL) == S_OK)
- {
- pConfig = (IConfiguration*)varPointer.pdispVal;
-
- ProcessConfig(pConfig);
-
- RELEASE(pConfig);
- };
- }
- catch (...)
- {
- TRACE("CRegenWizardAppWiz::CustomizeProject");
- };
-
- RELEASE(pConfigs);
- }
-
-
- // Here we define one instance of the CRegenWizardAppWiz class. You can access
- // m_Dictionary and any other public members of this class through the
- // global RegenWizardaw.
- CRegenWizardAppWiz RegenWizardaw;
-
-