How to create a Visual Studio project to compile the sample .NET Framework detection code
I posted some sample code a while back to demonstrate how to detect whether or not each version of the .NET Framework is installed, and if so, whether any service packs are installed. I only posted the source code for the samples. Since then, I've gotten a few questions about how to use Visual Studio to compile the code, so I decided to post the steps I use to create a Visual Studio project that can be used to compile the sample code:
- Start Visual Studio 2005 or Visual Studio 2008
- Click on the File menu, choose New | Project...
- In the Visual C++ node, select the Win32 project item, enter a project name and click OK
- Choose Windows Application in the wizard
- Right-click on your project in the Visual Studio solution explorer and choose Properties
- In the property pages, change the Configuration dropdown at the top from Active (Debug) to All Configurations
- Go to Configuration Properties | C/C++ | Precompiled Headers and change the Create/Use Precompiled Header from Use Precompiled Headers to Not Using Precompiled Headers
- Go to Configuration Properties | C/C++ | Command Line and add the /MT command line switch to the Additional options text box
- Click OK to dismiss the property pages
- Replace the contents of your main CPP file with the contents of one of the 2 sample code files described in this blog post
- Save all of the project files
- Build the project
<update date="11/12/2010"> Added a note about using the /MT command line switch to statically link to the Visual C++ runtime files to avoid dependency problems when running the sample code on other computers. </update>