Partager via


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:

  1. Start Visual Studio 2005 or Visual Studio 2008
  2. Click on the File menu, choose New | Project...
  3. In the Visual C++ node, select the Win32 project item, enter a project name and click OK
  4. Choose Windows Application in the wizard
  5. Right-click on your project in the Visual Studio solution explorer and choose Properties
  6. In the property pages, change the Configuration dropdown at the top from Active (Debug) to All Configurations
  7. Go to Configuration Properties | C/C++ | Precompiled Headers and change the Create/Use Precompiled Header from Use Precompiled Headers to Not Using Precompiled Headers
  8. Go to Configuration Properties | C/C++ | Command Line and add the /MT command line switch to the Additional options text box
  9. Click OK to dismiss the property pages
  10. Replace the contents of your main CPP file with the contents of one of the 2 sample code files described in this blog post
  11. Save all of the project files
  12. 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>

Comments