简体   繁体   English

使用 function IsWin2000() 会产生 C++ 警告:C4996 - 已弃用 Function

[英]Use of the function IsWin2000() produces a C++ warning: C4996 - Deprecated Function

So when I am using the function, IsWin2000(), to figure out whether or not the computer running my application is running windows 2000, i get the warning:因此,当我使用 function、IsWin2000() 来确定运行我的应用程序的计算机是否正在运行 windows 2000 时,我收到警告:

warning C4996: 'IsWin2000': This function is exported to support existing modules and is obsolete.

If this is an obsolete, deprecated function, what is the proper way to query what operating system is running?如果这是一个过时的、已弃用的 function,那么查询正在运行的操作系统的正确方法是什么? Is there any other way to achieve this task, or is my only option to simply suppress the warning?有没有其他方法可以完成这项任务,或者我唯一的选择是简单地抑制警告? Thanks!谢谢!

GetVersionEx

See the Remarks at OSVERSIONINFO for a list of results and how to interpret them.有关结果列表以及如何解释它们,请参阅OSVERSIONINFO的备注。 See Getting the System Version for a fully fledged example.有关完整示例,请参阅获取系统版本

And lets not forget what the spec says:并且不要忘记规范所说的内容:

Identifying the current operating system is usually not the best way to determine whether a particular operating system feature is present.识别当前操作系统通常不是确定是否存在特定操作系统功能的最佳方式。 This is because the operating system may have had new features added in a redistributable DLL.这是因为操作系统可能在可再发行的 DLL 中添加了新功能。 Rather than using GetVersionEx to determine the operating system platform or version number, test for the presence of the feature itself不要使用 GetVersionEx 来确定操作系统平台或版本号,而是测试功能本身是否存在

This is not a standard Windows API function.这不是标准的 Windows API function。 Maybe if you mention where you got it, we can provide more information.也许如果你提到你从哪里得到它,我们可以提供更多信息。

The proper way depends on what you are trying to accomplish.正确的方法取决于您要完成的工作。 Creating a debug log or error report, you should call GetVersionEx .创建调试日志或错误报告,您应该调用GetVersionEx

For any other purpose, you should test for the actual feature you're trying to use, often with GetProcAddress , and not hard-code a version test.对于任何其他目的,您应该测试您尝试使用的实际功能,通常使用GetProcAddress ,而不是硬编码版本测试。

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

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