WTL Wizard for Visual Studio 2008
Ah … I realized that this is going to be the first post in my blog … wow!
While the latest version of WTL was released last year, it was updated with whole bunch of Vista support. One thing that is really painful using non-MFC UI framework before is that there doesn’t have a good IDE support. A good news is that WTL 8.0 released with application wizards for both Visual C++ and Visual C++ Express. As easy as with MFC, a default project is created just with several mouse clicks.

It is very easy to install the wizard. After the WTL package is unzipped, there is a folder named ‘AppWiz’. Under which there are some javascript files for installing the wizard automatically. You only need to pick proper script for the different version of Visual Studio you installed. All easy shots. While this is very nice but one last minor issue is that at that time Visual Studio 2008 has not been released yet. Thus there is no install script for Visual Studio 2008.
I poked around internet and saw some people asking the question here and there. Actually the solution is pretty straight forward: open ‘setup80.js’ and edit it with notepad. Correct any registry key as if they are in Visual Studio 2008. Save it back, run it and you should be all set.
If you do not want to modify the script yourself, here is the code code I modified. Copy the code and save it at %WTL%\AppWiz\setup90.js. If you are in Vista, make sure you run it as Administrator. You are using the code at your own risk. No warrant is promised or implied by CodeGem.org.
// Windows Template Library - WTL version 8.0
// Copyright (C) Microsoft Corporation. All rights reserved.
//
// This file is a part of the Windows Template Library.
// The use and distribution terms for this software are covered by the
// Common Public License 1.0 (http://opensource.org/osi3.0/licenses/cpl1.0.php)
// which can be found in the file CPL.TXT at the root of this distribution.
// By using this software in any fashion, you are agreeing to be bound by
// the terms of this license. You must not remove this notice, or
// any other, from this software.
// Setup program for the WTL App Wizard for VC++ 9.0 (Orcas)
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");
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 strVC9Key = "HKLM\\Software\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
strValue = WSShell.RegRead(strVC9Key);
}
catch(e)
{
try
{
var strVC9Key_x64 = "HKLM\\Software\\Wow6432Node\\Microsoft\\VisualStudio\\9.0\\Setup\\VC\\ProductDir";
strValue = WSShell.RegRead(strVC9Key_x64);
}
catch(e)
{
WScript.Echo("ERROR: Cannot find where Visual Studio 9.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 += ".9.0";
else if(strLine.indexOf("WIZARD_VERSION") != -1)
strLine = "Param=\"WIZARD_VERSION = 9.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!");
}
Enjoy!
September 21st, 2008 at 9:53 am
Finally I got your first blog. Keep contribution to the world
November 3rd, 2008 at 3:53 pm
Where exactly do I put the AppWiz folder? I’m developing for Win Mobile, so where should I copy the AppWizMobile folder? Thanks for your help!!
November 5th, 2008 at 1:44 am
View the code and copy the code by yourself.
Do NOT be lazy and click the “copy to clipboard” link. By that link, all ‘<’ in the code will be changed to ‘<’, which makes the js invalid.
November 5th, 2008 at 1:45 am
oh, it changes back to ‘<’, I meant ‘& l t ;’, which is html code.
November 22nd, 2008 at 10:01 am
Thanks – this script saved me a bunch of time!
Also, knowing that WTL 8.0 works with VS 2008 was also very helpful, as this is not documented anywhere that I could find.
December 6th, 2008 at 1:41 pm
Thank you,
your post is highly ranked on google for “wtl vs 2008″
now I can migrate to vs2008
December 11th, 2008 at 7:10 am
Hi , I found this article helpful.
I am trying to make a project in VS 2005 as well as vs 2008 for Smart device.
My requirement is to call a webservice from managed C++.
After alot of search , i came to know about WTL Mobile application Wizard and downloaded WTL 8.0.
clicking on the .js file , was a sucess.
The issue is that I have the WTL Mobile application Wizard availabel as a template but after naming the project and clicking Ok , I a getting a message that Project creation is failed.
Can you help me with this?
December 17th, 2008 at 2:41 pm
Sounds great but you don’t mention any ATL specs. I’m having ATL dependency trouble getting WTL up. It may be the wrong version?
December 19th, 2008 at 4:41 pm
I have exactly the same problem – missing ATL dependency.
Does anybody know how to solve this problem?
January 20th, 2009 at 11:22 pm
It looks like there is no ATL with the included libraries/PSDK that comes with VC8 Express. You may have to grab a previous version ATL from an old PSDK, to get WTL working.
Kind of a pain considering ATL was once available with the PSDK….
It seems like MSFT hinted at including latest version of ATL in future releases…. but still nothing.
July 10th, 2009 at 10:01 am
I tried it, but received the error ‘cannot find where visual studio 9.0 is installed’.
August 2nd, 2009 at 5:32 am
I also received the same error as Peter.
Is there an update on this script?
Thanks
August 2nd, 2009 at 5:39 am
I replaced VisualStudio with VCExpress in the script and it works!
Thanks!
August 6th, 2009 at 7:32 pm
During deploiment of WTL80 I ran into a few problems.
VS2008 SP1 – inittially I replaced in AppWiz\setup80.js only REGISTRY related “8.0″ with “9.0″.
Wrong! The wizard was not writing anything after pressing the “Finish” button.
Replace ALL “8.0″ with “9.0″ and all will be kosher!
VC2009x – – inittially I replaced in AppWiz\setup80x.js only REGISTRY related “8.0″ with “9.0″.
Wrong! The WTL wizard is on the list but pressing OK in the “New Project” dialog just closes the dialog and dosen’t open “ATL/WTL application wizard”.
Replace ALL “8.0″ with “9.0″ and all will be kosher!
And then the “default” (i.e. with no changes) project does not build,because it is missing WTL dependancies.
I have WTL installed in C:\WTL80. Modify Project Properties:
1. In “C++/General/Adittional Include Directories” enter C:\WTL80\include
2. In “Resources/General/Adittional Include Directories” ADD C:\WTL80\include
To link I also had _ATL_DLL to “C++/Preprocessor/Preprocessor Definitions”
Now enjoy!
September 8th, 2009 at 9:16 pm
For VS 2008, Apart from modifying registry entries and executing the install script – Modify
\Program Files\Microsoft Visual Studio 9.0\VC\vcprojects\WTLAppWiz.vsz
for the following
Wizard=VsWizard.VsWizardEngine.9.0
Restart VS 2008, and Wizard works.
September 17th, 2009 at 5:29 pm
The latest WTL from sourceforge is version WTL81_9127 from May 07 2009. You don’t need to modify the install anymore. Anyway, thanks for the article!
November 8th, 2009 at 8:46 am
Thank you,it’s helpful.
March 23rd, 2010 at 8:00 am
Thanks a lot, it help me to update the WTL 8.0 to support the VC++ 2008, and now i can start build a nice UI…
April 20th, 2010 at 7:36 am
[...] ??? AppWiz ????? CodeGem ???????????????????? [...]