简体   繁体   中英

Windows API Codepack Backwards Compatibility on Windows XP

I don't have an XP machine handy. If I use the Windows API Codepack to do something new to Vista/Win7 (eg "TaskDialog") in C#, how does it cope with running on Windows XP machines?

If I use the Codepack, have I effectively made my application only support Vista and later versions of Windows?

If you look into "TaskDialog.cs", you will find that TastDialog's constructor includes the following lines:

// Throw PlatformNotSupportedException if the user is not running Vista or beyond
CoreHelpers.ThrowIfNotVista();

If you only include a reference to the Windows API Code Pack assembly, you will be fine. But using a feature which is not present on the OS currently running your application will throw an exception. To check if a feature is safe to call (ie supported on the current OS) most classes include a static IsPlatformSupported property.

So you could check TaskDialog.IsPlatformSupported first and call MessageBox.Show() instead if your OS doesn't support TaskDialogs.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM