简体   繁体   English

在C ++中检查Windows OS服务器版本

[英]Checking windows OS server version in c++

I am working on a C++ application. 我正在使用C ++应用程序。 I want to check the version of the OS on which my C++ application is running to take some action. 我想检查运行我的C ++应用程序的OS的版本以采取一些措施。 Basically, all I want to check if the OS version is Windows 2019 or not so that I can take some action. 基本上,我只想检查操作系统版本是否为Windows 2019,以便我可以采取一些措施。 I see that we can use the VersionHelpers.h as below 我看到我们可以如下使用VersionHelpers.h

   if (IsWindows8OrGreater())
    {
        printf("Windows8OrGreater\n");
    }

    if (IsWindows8Point1OrGreater())
    {
        printf("Windows8Point1OrGreater\n");
    }

    if (IsWindows10OrGreater())
    {
        printf("Windows10OrGreater\n");
    }

    if (IsWindowsServer())
    {
        printf("Server\n");
    }

However, I want to write only one if block to see if the version is windows 2019. Is there any way to do so? 但是,我只想编写一个if块以查看版本是否为Windows 2019.有什么方法可以这样做?

I think you can use VersifyVersionInfo to implement your own methods. 我认为您可以使用VersifyVersionInfo来实现自己的方法。 https://docs.microsoft.com/en-us/windows/desktop/api/Winbase/nf-winbase-verifyversioninfoa https://docs.microsoft.com/en-us/windows/desktop/api/Winbase/nf-winbase-verifyversioninfoa

Using this method you can know if it is not a specific version. 使用此方法,您可以知道它是否不是特定版本。

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

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