使用函数 IsWin2000() 会生成一个 C++警告:C4996 - 已弃用的函数
因此,当我使用函数 IsWin2000() 来确定运行我的应用程序的计算机是否正在运行 Windows 2000 时,我收到警告:
warning C4996: 'IsWin2000': This function is exported to support existing modules and is obsolete.
如果这是一个过时的、已弃用的函数,那么查询什么的正确方法是什么?操作系统正在运行?有没有其他方法可以完成此任务,或者我唯一的选择就是简单地抑制警告?谢谢!
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:
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? Is there any other way to achieve this task, or is my only option to simply suppress the warning? Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
GetVersionEx
请参阅
OSVERSIONINFO
查看结果列表以及如何解释它们。有关详细信息,请参阅获取系统版本完全成熟的例子。并且不要忘记规范所说的内容:
GetVersionEx
See the Remarks at
OSVERSIONINFO
for a list of results and how to interpret them. See Getting the System Version for a fully fledged example.And lets not forget what the spec says:
这不是标准的 Windows API 函数。也许如果您提及您从哪里获得它,我们可以提供更多信息。
正确的方法取决于您想要实现的目标。创建调试日志或错误报告,您应该调用
GetVersionEx
。出于任何其他目的,您应该测试您尝试使用的实际功能,通常使用
GetProcAddress
,而不是硬编码版本测试。This is not a standard 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
.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.