Why does GetFileVersionInfo on kernel32.dll in Windows 10 return version 6.2?(为什么 Windows 10 中 kernel32.dll 上的 GetFileVersionInfo 返回版本 6.2?)
问题描述
我正在尝试检索 kernel32.dll 版本以执行 Windows 版本检查.然而,出于某种原因,即使 kernel32.dll 的版本(如文件属性中所示)是 10.0.10586.0,返回的版本是:6.2.10586.0怎么来的?
I am trying to retrieve kernel32.dll version in order to perform a Windows version check. 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?
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 属性(与 SysWow64 相同):
Kernel32.dll properties (same as in SysWow64):
推荐答案
您从该任务的版本信息中读取了错误的字段.代替 dwFileVersionMS 和 dwFileVersionLS 使用 dwProductVersionMS 和 dwProductVersionLS.
You are reading the wrong fields from the version information for this task. Instead of dwFileVersionMS and dwFileVersionLS use dwProductVersionMS and dwProductVersionLS.
文件版本字段受supportedOS 兼容性问题的影响.也就是说,它们的值取决于应用程序清单中声明的 supportedOS 级别.另一方面,产品版本字段不依赖于清单.
The file version fields are subject to supportedOS compatibility issues. That is their values depend on the supportedOS levels declared in your application manifest. On the other hand the product version fields do not depend on the manifest.
这篇关于为什么 Windows 10 中 kernel32.dll 上的 GetFileVersionInfo 返回版本 6.2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:为什么 Windows 10 中 kernel32.dll 上的 GetFileVersionInfo 返回版本 6.2?
基础教程推荐
- 为什么 RegOpenKeyEx() 在 Vista 64 位上返回错误代码 2021-01-01
- 通过引用传递 C++ 迭代器有什么问题? 2022-01-01
- 初始化列表*参数*评估顺序 2021-01-01
- 为什么 typeid.name() 使用 GCC 返回奇怪的字符以及如 2022-09-16
- CString 到 char* 2021-01-01
- 我应该对 C++ 中的成员变量和函数参数使用相同的名称吗? 2021-01-01
- 为什么派生模板类不能访问基模板类的标识符? 2021-01-01
- 非静态 const 成员,不能使用默认赋值运算符 2022-10-09
- 如果我为无符号变量分配负值会发生什么? 2022-01-01
- GDB 显示调用堆栈上函数地址的当前编译二进制文 2022-09-05
