【发布时间】:2023-07-21 16:29:01
【问题描述】:
如果你在 cmd 中输入ver,你会得到类似:
Microsoft Windows [Version 10.0.17192.162]
我是否可以访问这些信息以在我的 C 程序中使用?我需要找到一个人正在运行的 Windows 版本。我已经检查了 SYSTEM_INFO:
typedef struct _SYSTEM_INFO {
union {
DWORD dwOemId;
struct {
WORD wProcessorArchitecture;
WORD wReserved;
};
};
DWORD dwPageSize;
LPVOID lpMinimumApplicationAddress;
LPVOID lpMaximumApplicationAddress;
DWORD_PTR dwActiveProcessorMask;
DWORD dwNumberOfProcessors;
DWORD dwProcessorType;
DWORD dwAllocationGranularity;
WORD wProcessorLevel;
WORD wProcessorRevision;
} SYSTEM_INFO;
和 OSVERSIONINFO
typedef struct _OSVERSIONINFOA {
DWORD dwOSVersionInfoSize;
DWORD dwMajorVersion;
DWORD dwMinorVersion;
DWORD dwBuildNumber;
DWORD dwPlatformId;
CHAR szCSDVersion[128];
} OSVERSIONINFOA, *POSVERSIONINFOA, *LPOSVERSIONINFOA;
但都不包含完整的版本信息。
另外,对于检索操作系统的名称,除了进行#ifdef __WIN32 检查之外还有其他方法吗?
【问题讨论】:
-
可能是XY Problem。您打算如何处理这些信息?
标签: c windows operating-system version