Getting the System Version(微软官方代码)

本文提供了一个C++示例程序,该程序使用GetVersionEx、GetSystemMetrics等函数来获取当前运行的操作系统的版本信息,并将这些信息显示在控制台上。此外,还介绍了如何通过调用GetFileVersionInfo函数获取完整版本号。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

The following example uses the GetVersionEx, GetSystemMetrics, GetProductInfo, and GetNativeSystemInfo functions to determine the version information of the currently running operating system. If compatibility mode is in effect, the example displays the operating system selected for application compatibility. The example displays the information to the console.

To obtain the full version number for the operating system, call the GetFileVersionInfo function on one of the system DLLs, such as Kernel32.dll, then call VerQueryValue to obtain the //StringFileInfo//<lang><codepage>//ProductVersion subblock of the file version information.

Relying on version information is not the best way to test for a feature. Instead, refer to the documentation for the feature of interest. For more information on common techniques for feature detection, see Operating System Version.

If you must require a particular operating system, be sure to use it as a minimum supported version, rather than design the test for the one operating system. This way, your detection code will continue to work on future versions of Windows.


PS C:\Windows\system32> pip install pyqt5 mido python-rtmidi pygame reportlab Defaulting to user installation because normal site-packages is not writeable Collecting pyqt5 Using cached PyQt5-5.15.11-cp38-abi3-win_amd64.whl.metadata (2.1 kB) Collecting mido Using cached mido-1.3.3-py3-none-any.whl.metadata (6.4 kB) Collecting python-rtmidi Using cached python_rtmidi-1.5.8.tar.gz (368 kB) Installing build dependencies ... done Getting requirements to build wheel ... done Preparing metadata (pyproject.toml) ... error error: subprocess-exited-with-error × Preparing metadata (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [20 lines of output] + meson setup D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7 D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7\.mesonpy-q_qt7g_w -Dbuildtype=release -Db_ndebug=if-release -Db_vscrt=md -Dwheel=true -Dverbose=false -Dbuildtype=plain --native-file=D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7\.mesonpy-q_qt7g_w\meson-python-native-file.ini The Meson build system Version: 1.7.0 Source dir: D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7 Build dir: D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7\.mesonpy-q_qt7g_w Build type: native build Project name: python-rtmidi Project version: 1.5.8 WARNING: Failed to activate VS environment: Could not find C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe ..\meson.build:1:0: ERROR: Unknown compiler(s): [['icl'], ['cl'], ['c++'], ['g++'], ['clang++'], ['clang-cl']] The following exception(s) were encountered: Running `icl ""` gave "[WinError 2] 系统找不到指定的文件。" Running `cl /?` gave "[WinError 2] 系统找不到指定的文件。" Running `c++ --version` gave "[WinError 2] 系统找不到指定的文件。" Running `g++ --version` gave "[WinError 2] 系统找不到指定的文件。" Running `clang++ --version` gave "[WinError 2] 系统找不到指定的文件。" Running `clang-cl /?` gave "[WinError 2] 系统找不到指定的文件。" A full log can be found at D:\Personal\Temp\pip-install-0i3_jjab\python-rtmidi_454ab6535b594e4ab017408bb4e727b7\.mesonpy-q_qt7g_w\meson-logs\meson-log.txt [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. error: metadata-generation-failed × Encountered error while generating package metadata. ╰─> See above for output. note: This is an issue with the package mentioned above, not pip. hint: See above for details.以上报错原因及解决办法
最新发布
03-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值