学习wtl 的安装方式 给vs 提供项目向导

http://www.codeproject.com/Tips/256944/Installing-the-WTL-Wizard-for-Visual-Studio-2010

到这里下http://wtl.svn.sourceforge.net/viewvc/wtl/trunk/wtl/Wizards/AppWiz.tar.gz?view=tar  WTL 8.1,然后点击setup100.js,就能安装了,安装成功后 就会弹出一个windows script host提示安装成功

现在看一下这个setup100。js 都是什么代码

// Setup program for the WTL App Wizard for VC++ 10.0 (VS2010)

main(); //执行main 函数

function main()
{
 // Decode command line arguments
 var bDebug = false;
 var bElevated = false;
 var Args = WScript.Arguments;
 for(var i = 0; i < Args.length; i++)
 {
  if(Args(i) == "/debug")
   bDebug = true;
  else if(Args(i) == "/elevated")
   bElevated = true;
 }

 // See if UAC is enabled
 var Shell = WScript.CreateObject("Shell.Application");// 用WSCRIPt 的shell 函数
 if(!bElevated && Shell.IsRestricted("System", "EnableLUA"))
 {
  // Check that the script is being run interactively.
  if(!WScript.Interactive)
  {
   WScript.Echo("ERROR: Elevation required.");
   return;
  }
  
  // Now relaunch the script, using the "RunAs" verb to elevate
  var strParams = "\"" + WScript.ScriptFullName + "\"";
  if (bDebug)
   strParams += " /debug";
  strParams += " /elevated";
  Shell.ShellExecute(WScript.FullName, strParams, null, "RunAs");
  return;
 }
 
 // Create shell object
 var WSShell = WScript.CreateObject("WScript.Shell");
 // Create file system object
 var FileSys = WScript.CreateObject("Scripting.FileSystemObject");

 // Get the folder containing the script file
 var strValue = FileSys.GetParentFolderName(WScript.ScriptFullName);
 if(strValue == null || strValue == "")
  strValue = ".";

 var strSourceFolder = FileSys.BuildPath(strValue, "Files");
 if(bDebug)
  WScript.Echo("Source: " + strSourceFolder);

 if(!FileSys.FolderExists(strSourceFolder))
 {
  WScript.Echo("ERROR: Cannot find Wizard folder (should be: " + strSourceFolder + ")");
  return;
 }

 try
 {
  var strVCKey = "HKLM\\Software\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir";
  strValue = WSShell.RegRead(strVCKey);
 }
 catch(e)
 {
  try
  {
   var strVCKey_x64 = "HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\10.0\\Setup\\VC\\ProductDir";
   strValue = WSShell.RegRead(strVCKey_x64);
  }
  catch(e)
  {
   WScript.Echo("ERROR: Cannot find where Visual Studio 10.0 is installed.");
   return;
  }
 }

 var strDestFolder = FileSys.BuildPath(strValue, "vcprojects");
 if(bDebug)
  WScript.Echo("Destination: " + strDestFolder);
 if(!FileSys.FolderExists(strDestFolder))
 {
  WScript.Echo("ERROR: Cannot find destination folder (should be: " + strDestFolder + ")");
  return;
 }

 // Copy files
 try
 {
  var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.ico");
  var strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.ico");
  FileSys.CopyFile(strSrc, strDest);

  strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsdir");
  strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.vsdir");
  FileSys.CopyFile(strSrc, strDest);
 }
 catch(e)
 {
  var strError = "no info";
  if(e.description.length != 0)
   strError = e.description;
  WScript.Echo("ERROR: Cannot copy file (" + strError + ")");
  return;
 }

 // Read and write WTLAppWiz.vsz, add engine version and replace path when found
 try
 {
  var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsz");
  var strDest = FileSys.BuildPath(strDestFolder, "WTLAppWiz.vsz");

  var ForReading = 1;
  var fileSrc = FileSys.OpenTextFile(strSrc, ForReading);
  if(fileSrc == null)
  {
   WScript.Echo("ERROR: Cannot open source file " + strSrc);
   return;
  }

  var ForWriting = 2;
  var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true);
  if(fileDest == null)
  {
   WScript.Echo("ERROR: Cannot open destination file" + strDest);
   return;
  }

  while(!fileSrc.AtEndOfStream)
  {
   var strLine = fileSrc.ReadLine();
   if(strLine.indexOf("Wizard=VsWizard.VsWizardEngine") != -1)
    strLine += ".10.0";
   else if(strLine.indexOf("WIZARD_VERSION") != -1)
    strLine = "Param=\"WIZARD_VERSION = 10.0\"";
   else if(strLine.indexOf("ABSOLUTE_PATH") != -1)
    strLine = "Param=\"ABSOLUTE_PATH = " + strSourceFolder + "\"";
   fileDest.WriteLine(strLine);
  }

  fileSrc.Close();
  fileDest.Close();
 }
 catch(e)
 {
  var strError = "no info";
  if(e.description.length != 0)
   strError = e.description;
  WScript.Echo("ERROR: Cannot read and write WTLAppWiz.vsz (" + strError + ")");
  return;
 }

 // Create WTL folder
 var strDestWTLFolder = "";
 try
 {
  strDestWTLFolder = FileSys.BuildPath(strDestFolder, "WTL");
  if(!FileSys.FolderExists(strDestWTLFolder))
   FileSys.CreateFolder(strDestWTLFolder);
  if(bDebug)
   WScript.Echo("WTL Folder: " + strDestWTLFolder);
 }
 catch(e)
 {
  var strError = "no info";
  if(e.description.length != 0)
   strError = e.description;
  WScript.Echo("ERROR: Cannot create WTL folder (" + strError + ")");
  return;
 }

 // Read and write additional WTLAppWiz.vsdir, add path to the wizard location
 try
 {
  var strSrc = FileSys.BuildPath(strSourceFolder, "WTLAppWiz.vsdir");
  var strDest = FileSys.BuildPath(strDestWTLFolder, "WTLAppWiz.vsdir");

  var ForReading = 1;
  var fileSrc = FileSys.OpenTextFile(strSrc, ForReading);
  if(fileSrc == null)
  {
   WScript.Echo("ERROR: Cannot open source file " + strSrc);
   return;
  }

  var ForWriting = 2;
  var fileDest = FileSys.OpenTextFile(strDest, ForWriting, true);
  if(fileDest == null)
  {
   WScript.Echo("ERROR: Cannot open destination file" + strDest);
   return;
  }

  while(!fileSrc.AtEndOfStream)
  {
   var strLine = fileSrc.ReadLine();
   if(strLine.indexOf("WTLAppWiz.vsz|") != -1)
    strLine = "..\\" + strLine;
   fileDest.WriteLine(strLine);
  }

  fileSrc.Close();
  fileDest.Close();
 }
 catch(e)
 {
  var strError = "no info";
  if(e.description.length != 0)
   strError = e.description;
  WScript.Echo("ERROR: Cannot read and write WTL\\WTLAppWiz.vsdir (" + strError + ")");
  return;
 }

 WScript.Echo("App Wizard successfully installed!"); // 弹出对话框
}

 整个过程就是用WScript将setup100js 文件夹下的文件复制到vs安装向导目录,这样vs vc++ 项目模板里就有wtl 的向导了,但是我按照向导作了个例子运行不成功,难道没有安装wtl 的库?

http://sourceforge.net/projects/wtl/ 下载wtl 库, 解压之后,运行例子还是不行。提示找不到头文件,然后右击项目,c属性 ,c++目录,在包含里面添加C:\WTL80\include(文件解压的位置),这个, 不过还是不行,说

错误 2 error CVT1100: 资源重复。类型: MANIFEST,名称: 1,语言: 0x0409 C:\WTL80\Samples\WTLExplorer\CVTRES WTLExplorer

错误 3 error LNK1123: 转换到 COFF 期间失败: 文件无效或损坏 C:\WTL80\Samples\WTLExplorer\LINK WTLExplorer ,不知道为什么

 新建个项目提示错误 2 error C3861: “AtlLoadIconImage”: 找不到标识符 c:\users\zhangchao\documents\visual studio 2010\projects\wtltest2\wtltest2\maindlg.h 46 1 wtltest2 ,艾不知道怎么搞得, 还是看看中文的开发指南巴

你可能感兴趣的:(安装)