简体   繁体   English

Windows XP上的Windows API Codepack向后兼容性

[英]Windows API Codepack Backwards Compatibility on Windows XP

I don't have an XP machine handy. 我没有方便的XP机器。 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? 如果我使用Windows API Codepack在C#中对Vista / Win7做一些新的事情(例如“TaskDialog”),它如何应对在Windows XP机器上运行?

If I use the Codepack, have I effectively made my application only support Vista and later versions of Windows? 如果我使用Codepack,我是否有效地使我的应用程序仅支持Vista和更高版本的Windows?

If you look into "TaskDialog.cs", you will find that TastDialog's constructor includes the following lines: 如果你查看“TaskDialog.cs”,你会发现TastDialog的构造函数包括以下几行:

// 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. 如果您只包含对Windows API代码包程序集的引用,那么您将没问题。 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. 要检查某个功能是否可以安全调用(即当前操作系统支持),大多数类都包含静态IsPlatformSupported属性。

So you could check TaskDialog.IsPlatformSupported first and call MessageBox.Show() instead if your OS doesn't support TaskDialogs. 因此,如果您的操作系统不支持TaskDialogs,您可以首先检查TaskDialog.IsPlatformSupported并调用MessageBox.Show()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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