Wiki Link: [discussion:1667]
Usage in an application that will run on XP, Vista, and Windows 7 

May 4 2009 at 6:59 AM
What's the correct way to use this code in a backwards compatible application? I'd expect either error checking for unsupported methods or a utility method that said whether or not Windows 7 features are supported. Is the idea that I should query System.Environment.OSVersion.Major >=6 && System.Environment.OSVersion.Minor >=1?

May 12 2009 at 5:24 AM
Hi Jon,
This is a great question. Version checking is always tricky since it is highly not recommended procedure to verify the availability of specific features in a given OS. Checking OS version is often not the best to check if a specific OS feature is available. Some OS features may be added to previous versions of Windows as redistributable files. For example, the Direct2D & DirectWrite APIs and the Ribbon API are planned to be made available in Windows Vista so there is no need to block your application from using these APIs. Therefore it is recommended to test for features.
Specifically, for Windows API Code Pack if you try use a feature that is dedicated for Windows 7 it will throw an exception at you, so you don’t really need to check for version.

Sep 27 2010 at 3:37 PM
Having exceptions thrown is not a very nice environment even when they are handled by the caller. Each caller of the API has to develop the workaround for the exception which is pretty much rewriting the API in the callers code.

Much of the API does not use the COM Interop externs directly, but instead, has a managed wrapper too.
For instance, the Microsoft.WindowsAPICodePack.Controls.WindowsForms.ExplorerBrowser wrapper uses a specific coclass (Microsoft.WindowsAPICodePack.Controls.ExplorerBrowserClass) that does not exist on Windowss XP machines. The wrapper could have used the appropriate COM class depending on the user's environment (@ runtime; not compile time). The API would be better at handling the compatibility than the callers of the API.

Are their any plans to widen the scope of the APIs to modern o/s versions that have the same functionality in a more uniform manner? For instance, It would be nice if the knownfolders and WindowsForms.ExplorerBrowser APi would reveal the appropriate o/s features under a single API. This abstraction would also allow MS design changes to be made quicker and easier since it would not force callers of the API to use older APIs in their code for unsupported features.

Jul 8 2011 at 4:29 PM
Slightly late of a reply but for those who need to know:
Most of the Vista+ only feature in the Code Pack have a static property IsPlatformSupported which you can test against to know if the platform (OS) supports the feature.

Page view tracker