Monday, November 27, 2006

Unspecialized class template can't be used ...

Ever had fun with Compiler Error C3203 and Visual Studio 2005 (VC8)? I maintain a project that uses the Windows Template Library (WTL). When upgrading the project to use VC8 I noticed hundreds upon hundreds of compile errors with this cryptic statement "unspecialized class template can't be used as a template argument for template parameter 'T', expected a real type".

Here's Microsoft's explanation:
Here's my translation:

Say you have a class definition something like below. Pay attention to the text in bold.

template <class TItem = CCustomTabItem>
class CDotNetButtonTabCtrl :
public CCustomTabCtrl<CDotNetButtonTabCtrl, TItem>

Change the code to below so it will compile, and your C3203 compile errors will disappear.

template <class TItem = CCustomTabItem>
class CDotNetButtonTabCtrl :
public CCustomTabCtrl<CDotNetButtonTabCtrl<TItem>, TItem>

Tuesday, November 21, 2006

Windows Vista CreateProcess Issues

Windows Vista has been nothing but fun. I came across an issue where all CreateProcess calls in the application I'm upgrading to Vista now fail. The processes are launched from within a GUI application. The launched process requires Administrator rights. The launched process was upgraded to include the appropriate Vista Maniftest, though when launched from the old application the CreateProcess call fails with error 740 ERROR_ELEVATION_REQUIRED.

Turns out I can no longer use CreateProcess to launch the process. I have to use ShellExecute instead.

0, // params
0, // directory

I've found this resources somewhat useful Microsoft Vista Developer Reference. Though most of Microsoft's Vista documentation tends to be a bunch of marketing fluff with no real substance. My favorite example of this can be found here. In it's current state the article is nothing more than a poorly organized mess, sprinkled with keywords, giving the developer no real hope of ever figuring out what wonderful changes are ahead with Microsoft Vista.

Monday, November 20, 2006

Ode to the Doctor's Excuse

Doctor's excuse oh Doctor's excuse why do I need thee? Did I fall out of bed and break my head?
Or am I just to lazy? I've been so sick I fear my rear is stuck to the bed though I am not dead.
For work for school the form I seek, but don't know where to find it? Where can I go, I do not know? The doctor I know is not willing to give it. Unless, I get out of bed and drive to town and ask him for the Doctor's Excuse Form. Signed by him or maybe her, it doesn't matter. As long as my boss or maybe my teacher doesn't fire me over the matter.

Sunday, November 19, 2006

The Egg Roll

My wife made some Hmong Egg Rolls for me. I have to say they were so yummy! Best Egg Rolls I've had in a long time. Here's the recipe. I think the secret to the egg roll recipe is letting the bean thread soak up all the juices from the cilantro, meat, and other ingredients. Then when you cook them in the peanut oil ... delicious!! I've seen a few other recipes for Hmong egg rolls around some better than others. If you were to search for Hmong egg rolls you'll also see it called kabyob; which is just how to spell egg roll in in the Hmong language. Kabyob pronounced more like ga yaw in English means egg roll. Each Hmong family tends to have their own egg roll recipe, not really written down, but adapted to their own tastes.

Friday, November 17, 2006

Windows Vista Code Signing

Windows Vista Code Signing. Seems with Windows latest OS code signing isn't optional. Its something you need to do. Why? Cause if you don't Windows Vista makes your program to appear as if it's a malware or a virus program. The "Do you really want to do this?" and "Are you really, really sure?" dialogs are all over the place in Windows Vista. So bottom line, you need to sign your executables.

Code signing has actually gotten easier over the years. You used to have to download the Microsoft Code Signing Tool. Now it just comes bundled with Visual Studio; which actually makes things a little easier.

So first off, you need to get a Code Signing Certificate. These can be obtained from a Windows Vista Trusted Certificate Authority (CA). Verisign, Thawte, and GeoTrust are the big ones (Though Thawte is owned by Verisign). You'll need to order a Microsoft Authenticode signing certificate. The company you purchase from can walk you through the step of generating the certificate.

Once you have a certificate you can add a post build event to your visual studio project that will sign the exe, or dll after it's built. The command to run will look something like this:

signcode.exe -v your.pvk -spc your.spc $(OutDir)\$(TargetFileName) -t

You'll probably find these links helpful:

SignCode.exe Documentation
SignTool.exe Documentation
Cert2Spc.exe Documentation

Wednesday, November 15, 2006

Windows Vista Manifest File Issues

In the process of upgrading a product to work with Windows Vista and having way to much fun.

Part of my issues have been with adding the new requestedExecutionLevel to an exe so it can be run as an administrator.

Per Microsoft Vista Documentation a manifest needs to be added which adds the appropriate requestedExecutionLevel, in my case administrator.

So how do you add the requestedExecutionlevel to a program?

1) Create a file and paste the required XML found in the Microsoft Vista Documentation

It looks something like this:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestversion="1.0">
<trustinfo xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedexecutionlevel level="requireAdministrator" uiaccess="false">

2) Tell VC8 about the manifest file you just created. From the VC8 project properties you need to go to Manifest Tool > Input and Output > Additional Manifest Files. Set Additional Manifest Files to be the filename you created above.

3) Compile your project.

If you have a working Manifest Tool program, your program will now have a good manifest file. If you don't, then the manifest created will be broken, and your program will have a great feature when run on Windows XP. It will automatically reboot the computer for you!! Isn't that wonderful?

The fix for this Windows Vista Manifest crash on Windows XP is a gem I found in one of the Microsoft Forumns. Since it is a gem, the solution is buried away in the forumn. Here is the gem:

In Windows Visual Studio 2005 there are multiple copies of the mt.exe (Manifest Tool) program. There is an older version in the $InstallDir\VC\bin that you need to replace with the mt.exe found in $InstallDir\Common7\Tools\Bin.

Follow the above steps and you should have a program that will run as an administrator on Windows Vista and actually work on previous versions of Windows without crashing. (Always a plus)

Possible additional steps, use your code signing certificate and sign the executable for a more user friendly dialog when your program is run on Windows Vista.