Friday, December 29, 2006

C/C++ and Distributing a VC8 application

C/C++ in Visual Studio 8 has changed once again. Seems Microsoft can't decide on the best way to handle their C/C++ runtime dlls (CRT).

VC6 and dll hell was fun.

VC7, VC7.1 got better because the compiler was a bit more standard. Redistributing files wasn't as bad, just copy msvcrt71.dll or msvcr71.dll to your application directory and things worked.

VC8 changes things once again. Introducing side-by-side assemblies. If I were a C# guy, I'm sure I'd be familiar with assemblies by now, but alas, I prefer the C/C++. So here are some links on how to deal with the VC8 CRT dlls, so that your applications don't crash after you distribute them because your missing required dlls.

Friday, December 08, 2006

Vista Manifest Crash

Since a lot of people are searching for it here it is again.

Out of the box, when you create a manifest using Windows Visual Studio 2005 your program will crash when run on Non Windows Vista boxes. Microsoft uses a gentler word and says reboot in their KB article.

To fix the Vista Manifest Crash issue taken from my previous blog entry:

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.

After you replace the mt.exe file with the one that works. Rebuild your project and the manifest file will be created properly. Your program will no longer crash when run on non vista boxes.

Wednesday, December 06, 2006

Windows Vista Launch Developer Resource DVD

Got the Windows Vista Launch Developer Resource DVD in the mail today. Found it extremely funny that it didn't run properly on my Windows Vista Ultimate test computer. So if Microsoft can't even get their programs to work right on Vista, what are the rest of us to do?

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.


::ShellExecute(
m_hWnd,
_T("runas"),
szProcess,
0, // params
0, // directory
SW_SHOWNORMAL
);



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 http://timestamp.verisign.com/scripts/timstamp.dll

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">
<security>
<requestedprivileges>
<requestedexecutionlevel level="requireAdministrator" uiaccess="false">
</requestedexecutionlevel>
</requestedprivileges>
</security>
</trustinfo>



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.








Tuesday, October 17, 2006

In search of a good website stat counter

Looking for some good website stat counters. I've been using http://statcounter.com.

Came across http://103bees.com impressed by how it helps you with search terms. Also pretty fond of http://www.google.com/analytics.

Any better ones out there?

Saturday, October 14, 2006

Fishing in Idaho Falls

So I had the chance to go fishing last week. Went over to the North Power Plant in Idaho Falls. Fishing wasn't too bad. A lot of walking though. When I first arrived there was a group fishing just below the first damn. I ended up crossing over the damn and looking for some holes along the east side of the river. It started to rain, good thing I brought my waterproof jacket. Nothing but nibbles so I hoofed it up to the sunset on the snake geocache. No luck up there either so I went over to the second damn. Tripped in a few puddles, rather frustrating I wasn't wet yet, now I was soaked. Couldn't give up yet, I was hungry for some fish. Found a hole and to my suprise got a nibble. Tried again and caught myself a 13in Rainbow Trout. (This is my first year fishing) So I was pretty excited. Went home cooked it up. Sure was yummy.