标签:des style blog color os 文件 io for
function OnFinish(selProj, selObj) { try { var strProjectPath = wizard.FindSymbol(‘PROJECT_PATH‘); var strProjectName = wizard.FindSymbol(‘PROJECT_NAME‘); selProj = CreateCustomProject(strProjectName, strProjectPath); AddConfig(selProj, strProjectName); AddFilters(selProj); var InfFile = CreateCustomInfFile(); AddFilesToCustomProj(selProj, strProjectName, strProjectPath, InfFile); PchSettings(selProj); InfFile.Delete(); selProj.Object.Save(); } catch(e) { if (e.description.length != 0) SetErrorInfo(e); return e.number } } function CreateCustomProject(strProjectName, strProjectPath) { try { var strProjTemplatePath = wizard.FindSymbol(‘PROJECT_TEMPLATE_PATH‘); var strProjTemplate = ‘‘; strProjTemplate = strProjTemplatePath + ‘\\default.vcproj‘; var Solution = dte.Solution; var strSolutionName = ""; if (wizard.FindSymbol("CLOSE_SOLUTION")) { Solution.Close(); strSolutionName = wizard.FindSymbol("VS_SOLUTION_NAME"); if (strSolutionName.length) { var strSolutionPath = strProjectPath.substr(0, strProjectPath.length - strProjectName.length); Solution.Create(strSolutionPath, strSolutionName); } } var strProjectNameWithExt = ‘‘; strProjectNameWithExt = strProjectName + ‘.vcproj‘; var oTarget = wizard.FindSymbol("TARGET"); var prj; if (wizard.FindSymbol("WIZARD_TYPE") == vsWizardAddSubProject) // vsWizardAddSubProject { var prjItem = oTarget.AddFromTemplate(strProjTemplate, strProjectNameWithExt); prj = prjItem.SubProject; } else { prj = oTarget.AddFromTemplate(strProjTemplate, strProjectPath, strProjectNameWithExt); } var fxtarget = wizard.FindSymbol("TARGET_FRAMEWORK_VERSION"); if (fxtarget != null && fxtarget != "") { fxtarget = fxtarget.split(‘.‘, 2); if (fxtarget.length == 2) prj.Object.TargetFrameworkVersion = parseInt(fxtarget[0]) * 0x10000 + parseInt(fxtarget[1]) } return prj; } catch(e) { throw e; } } function AddFilters(proj) { try { // 将文件夹添加到项目 // var strSrcFilter = wizard.FindSymbol(‘SOURCE_FILTER‘); // var group = proj.Object.AddFilter(‘源文件‘); // group.Filter = strSrcFilter; proj.Object.AddFilter(‘源文件‘).Filter = ‘cpp;c;def‘; proj.Object.AddFilter(‘头文件‘).Filter = ‘hpp;h‘; proj.Object.AddFilter(‘资源文件‘).Filter = ‘ico;rc;bin‘; } catch(e) { throw e; } } function AddConfig(proj, strProjectName) { try { var config = proj.Object.Configurations(‘Debug‘); config.CharacterSet = charSetUNICODE; config.ConfigurationType = typeDynamicLibrary; config.IntermediateDirectory = ‘$(ConfigurationName)‘; config.OutputDirectory = ‘$(ConfigurationName)‘; var CLTool = config.Tools(‘VCCLCompilerTool‘); // TODO: 添加编译器设置 CLTool.RuntimeLibrary = rtMultiThreadedDebugDLL; var strDefines = CLTool.PreprocessorDefinitions; if (strDefines != "") strDefines += ";"; strDefines += GetPlatformDefine(config); strDefines += "_DEBUG"; strDefines += ";_WINDOWS;_USRDLL;"; var strExports = strProjectName.toString().toUpperCase() + "_EXPORTS"; strDefines += strExports; CLTool.PreprocessorDefinitions = strDefines; CLTool.DebugInformationFormat = debugEditAndContinue; var LinkTool = config.Tools(‘VCLinkerTool‘); // TODO: 添加链接器设置 LinkTool.ModuleDefinitionFile = strProjectName+".def"; LinkTool.GenerateDebugInformation = true; LinkTool.SubSystem = subSystemWindows; config = proj.Object.Configurations(‘Release‘); config.IntermediateDirectory = ‘$(ConfigurationName)‘; config.OutputDirectory = ‘$(ConfigurationName)‘; config.CharacterSet = charSetUNICODE; config.ConfigurationType = typeDynamicLibrary; var CLTool = config.Tools(‘VCCLCompilerTool‘); // TODO: 添加编译器设置 CLTool.RuntimeLibrary = rtMultiThreadedDLL; var strDefines = CLTool.PreprocessorDefinitions; if (strDefines != "") strDefines += ";"; strDefines += GetPlatformDefine(config); strDefines += "NDEBUG" strDefines += ";_WINDOWS;_USRDLL;"; var strExports = strProjectName.toString().toUpperCase() + "_EXPORTS"; strDefines += strExports; CLTool.PreprocessorDefinitions = strDefines; CLTool.DebugInformationFormat = debugEnabled; var LinkTool = config.Tools(‘VCLinkerTool‘); // TODO: 添加链接器设置 LinkTool.ModuleDefinitionFile = strProjectName+".def"; LinkTool.GenerateDebugInformation = true; LinkTool.SubSystem = subSystemWindows; } catch(e) { throw e; } } function PchSettings(proj) { // TODO: 指定 pch 设置 } function DelFile(fso, strWizTempFile) { try { if (fso.FileExists(strWizTempFile)) { var tmpFile = fso.GetFile(strWizTempFile); tmpFile.Delete(); } } catch(e) { throw e; } } function CreateCustomInfFile() { try { var fso, TemplatesFolder, TemplateFiles, strTemplate; fso = new ActiveXObject(‘Scripting.FileSystemObject‘); var TemporaryFolder = 2; var tfolder = fso.GetSpecialFolder(TemporaryFolder); var strTempFolder = tfolder.Drive + ‘\\‘ + tfolder.Name; var strWizTempFile = strTempFolder + "\\" + fso.GetTempName(); var strTemplatePath = wizard.FindSymbol(‘TEMPLATES_PATH‘); var strInfFile = strTemplatePath + ‘\\Templates.inf‘; wizard.RenderTemplate(strInfFile, strWizTempFile); var WizTempFile = fso.GetFile(strWizTempFile); return WizTempFile; } catch(e) { throw e; } } function GetTargetName(strName, strProjectName) { try { // TODO: 基于模板文件名设置呈现文件的名称 var strTarget = strName; if (strName == ‘readme.txt‘) strTarget = ‘ReadMe.txt‘; if (strName == ‘MoonDriver.cpp‘) strTarget =strProjectName+ ‘.cpp‘; if (strName == ‘MoonDriver.def‘) strTarget =strProjectName+ ‘.def‘; if (strName == ‘MoonDriver.h‘) strTarget =strProjectName+ ‘.h‘; return strTarget; } catch(e) { throw e; } } function AddFilesToCustomProj(proj, strProjectName, strProjectPath, InfFile) { try { var projItems = proj.ProjectItems var strTemplatePath = wizard.FindSymbol(‘TEMPLATES_PATH‘); var strTpl = ‘‘; var strName = ‘‘; var strTextStream = InfFile.OpenAsTextStream(1, -2); while (!strTextStream.AtEndOfStream) { strTpl = strTextStream.ReadLine(); if (strTpl != ‘‘) { strName = strTpl; var strTarget = GetTargetName(strName, strProjectName); var strTemplate = strTemplatePath + ‘\\‘ + strTpl; var strFile = strProjectPath + ‘\\‘ + strTarget; var bCopyOnly = false; //“true”仅将文件从 strTemplate 复制到 strTarget,而不对项目进行呈现/添加 var strExt = strName.substr(strName.lastIndexOf(".")); if(strExt==".bmp" || strExt==".ico" || strExt==".gif" || strExt==".rtf" || strExt==".css"|| strExt==".lib") bCopyOnly = true; wizard.RenderTemplate(strTemplate, strFile, bCopyOnly); proj.Object.AddFile(strFile); } } strTextStream.Close(); } catch(e) { throw e; } }
VS2008 自定义向导的default.js设置(DLL文件),布布扣,bubuko.com
VS2008 自定义向导的default.js设置(DLL文件)
标签:des style blog color os 文件 io for
原文地址:http://www.cnblogs.com/elonlee/p/3878596.html