简体   繁体   English

为什么Windows 10中的kernel32.dll上的GetFileVersionInfo返回版本6.2?

[英]Why does GetFileVersionInfo on kernel32.dll in Windows 10 return version 6.2?

I am trying to retrieve kernel32.dll version in order to perform a Windows version check. 我正在尝试检索kernel32.dll版本以执行Windows版本检查。 Yet, for some reason, even though kernel32.dll 's version (as seen in file properties) is 10.0.10586.0, the returned version is: 6.2.10586.0 how come? 然而,由于某种原因,即使kernel32.dll的版本(如文件属性中所示)是10.0.10586.0,返回的版本是:6.2.10586.0怎么来的?

    DWORD dwDummy;
    DWORD dwFVISize = GetFileVersionInfoSize(lpszFilePath, &dwDummy);
    LPBYTE lpVersionInfo = new BYTE[dwFVISize];
    if (GetFileVersionInfo(lpszFilePath, 0, dwFVISize, lpVersionInfo) == 0)
    {
        return FALSE;
    }

    UINT uLen;
    VS_FIXEDFILEINFO *lpFfi;
    BOOL bVer = VerQueryValue(lpVersionInfo, L"\\", (LPVOID *)&lpFfi, &uLen);

    if (!bVer || uLen == 0)
    {
        return FALSE;
    }
    DWORD dwFileVersionMS = lpFfi->dwFileVersionMS;
    DWORD dwFileVersionLS = lpFfi->dwFileVersionLS;
    delete[] lpVersionInfo;

    DWORD dwLeftMost = HIWORD(dwFileVersionMS);
    DWORD dwSecondLeft = LOWORD(dwFileVersionMS);
    DWORD dwSecondRight = HIWORD(dwFileVersionLS);
    DWORD dwRightMost = LOWORD(dwFileVersionLS);

Kernel32.dll properties (same as in SysWow64): Kernel32.dll属性(与SysWow64中的相同): 在此输入图像描述

You are reading the wrong fields from the version information for this task. 您正在从此任务的版本信息中读取错误的字段。 Instead of dwFileVersionMS and dwFileVersionLS use dwProductVersionMS and dwProductVersionLS . 而不是dwFileVersionMSdwFileVersionLS使用dwProductVersionMSdwProductVersionLS

The file version fields are subject to supportedOS compatibility issues. 文件版本字段受supportedOS兼容性问题的影响。 That is their values depend on the supportedOS levels declared in your application manifest. 这是它们的值取决于应用程序清单中声明的supportedOS级别。 On the other hand the product version fields do not depend on the manifest. 另一方面,产品版本字段不依赖于清单。

Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). 未在Windows 8.1或Windows 10中显示的应用程序将返回Windows 8 OS版本值(6.2)。

this is from GetVersionEx function MSDN description. 这是来自GetVersionEx函数的MSDN描述。 for GetFileVersionInfo no such note, but really this doing same. 对于GetFileVersionInfo没有这样的说明,但真的这样做。 i look under debugger: 我在调试器下看: 在此输入图像描述

在此输入图像描述

so 10.0 ( 0xA000) in dwFileVersionMS can be fixed to 6.2 or 6.3 but dwProductVersionMS - not changed (0xA000 ~ 10.0) think need fix MSDN documentation for GetFileVersionInfo[Ex] :) 所以dwFileVersionMS中的10.0(0xA000)可以固定为6.2或6.3,但dwProductVersionMS - 未更改(0xA000~10.0)认为需要修复GetFileVersionInfo的MSDN文档[Ex] :)

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

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