参考这个答案,我正在尝试使用GetFileVersionInfo方法通过 Windows Api 获取 ProductVersion。问题是通过 .exe ProductVersion 的属性是可见的,但以编程方式我只得到“0.0.0.0”。
.exe 属性:
输出:
代码:
printf( "File Version 1: %d.%d.%d.%d\n",
( verInfo->dwFileVersionMS >> 16 ) & 0xffff,
( verInfo->dwFileVersionMS >> 0 ) & 0xffff,
( verInfo->dwFileVersionLS >> 16 ) & 0xffff,
( verInfo->dwFileVersionLS >> 0 ) & 0xffff
);
printf( "File Version 2: %d.%d.%d.%d\n",
( verInfo->dwFileVersionLS >> 24 ) & 0xff,
( verInfo->dwFileVersionLS >> 16 ) & 0xff,
( verInfo->dwFileVersionLS >> 8 ) & 0xff,
( verInfo->dwFileVersionLS >> 0 ) & 0xff
);
printf( "Product Version 1: %d.%d.%d.%d\n",
( verInfo->dwProductVersionLS >> 24 ) & 0xff,
( verInfo->dwProductVersionLS >> 16 ) & 0xff,
( verInfo->dwProductVersionLS >> 8 ) & 0xff,
( verInfo->dwProductVersionLS >> 0 ) & 0xff
);
printf( "Product Version 2: %d.%d.%d.%d\n",
(verInfo->dwProductVersionMS >> 16) & 0xffff,
(verInfo->dwProductVersionMS >> 0) & 0xffff,
(verInfo->dwProductVersionLS >> 16) & 0xffff,
(verInfo->dwProductVersionLS >> 0) & 0xffff
);
printf( "Product Version 3: %d.%d.%d.%d\n",
(verInfo->dwProductVersionMS >> 16) & 0xffff,
(verInfo->dwProductVersionMS >> 8) & 0xffff,
(verInfo->dwProductVersionLS >> 16) & 0xffff,
(verInfo->dwProductVersionLS >> 8) & 0xffff
);
问题是-WTF?如何获得 ProductVersion,微软的人是如何做到的?