Mailbag: How to create a Visual Studio project to compile the sample .NET Framework detection code
I have downloaded both versions of the sample .NET Framework version detection code (described here and here), and I am trying to compile it to test it out on my system. However, I am running into issues trying to create a Visual Studio project that will correctly build the sample code. What do I need to do to get this sample code to compile on my system?
You should be able to use the following steps to create a project and compile the sample .NET Framework detection code using either Visual Studio 2005 or Visual Studio 2008:
- Start Visual Studio 2005 or Visual Studio 2008 (the steps are equivalent in both versions of VS)
- Click on the File menu, choose File | New | Project...
- In the Visual C++ node, select the Win32 project item, provide a name and click OK
- In the Win32 Application Wizard dialog, click Next on the Overview screen
- Select Windows Application on the Application Settings screen (but do not change any of the other settings) and click Finish
- Right-click on your project in the Visual Studio Solution Explorer and choose Properties
- In the property pages, change the Configuration drop down 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 Header (/Yu) to Not Using Precompiled Headers
- Click OK to dismiss the property pages
- Replace the contents of your main CPP file with the contents of the file from my blog post (the original detection sample, or the enhanced sample that does some additional checks behind the scenes)
- Save all of the project files
- Build the project
Note - while testing the above steps, I noticed that the sample code was generating several warnings during the build process. I fixed these and posted updated versions of both samples that will build by default without any warnings.