Created
January 17, 2016 10:58
-
-
Save m13253/b636ff7974271618b25e to your computer and use it in GitHub Desktop.
GetVersionEx - Print Windows version information
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <windows.h> | |
int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int nShowCmd) { | |
OSVERSIONINFOEXW version_info; | |
ZeroMemory(&version_info, sizeof version_info); | |
version_info.dwOSVersionInfoSize = sizeof version_info; | |
if(GetVersionExW((LPOSVERSIONINFOW) &version_info)) { | |
wprintf(L"OSVERSIONINFOEX {\n"); | |
wprintf(L"\tdwOSVersionInfoSize\t= %u,\n", version_info.dwOSVersionInfoSize); | |
wprintf(L"\tdwMajorVersion\t\t= %u,\n", version_info.dwMajorVersion); | |
wprintf(L"\tdwMinorVersion\t\t= %u,\n", version_info.dwMinorVersion); | |
wprintf(L"\tdwBuildNumber\t\t= %u,\n", version_info.dwBuildNumber); | |
wprintf(L"\tdwPlatformId\t\t= %u,\n", version_info.dwPlatformId); | |
wprintf(L"\tszCSDVersion\t\t= \"%ls\",\n", version_info.szCSDVersion); | |
wprintf(L"\twServicePackMajor\t= %u,\n", version_info.wServicePackMajor); | |
wprintf(L"\twServicePackMinor\t= %u,\n", version_info.wServicePackMinor); | |
wprintf(L"\twSuiteMask\t\t= 0x%04x,\n", version_info.wSuiteMask); | |
wprintf(L"\twProductType\t\t= 0x%02x,\n", version_info.wProductType); | |
wprintf(L"\twReserved\t\t= 0x%02x\n", version_info.wReserved); | |
wprintf(L"}\n"); | |
} else { | |
DWORD err = GetLastError(); | |
wprintf(L"GetVersionEx: Error %u\n", err); | |
ExitProcess(err); | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> | |
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> | |
<assemblyIdentity | |
type="win32" | |
name=SXS_ASSEMBLY_NAME | |
version=SXS_ASSEMBLY_VERSION | |
processorArchitecture=SXS_PROCESSOR_ARCHITECTURE | |
/> | |
<description>GetVersionEx</description> | |
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> | |
<security> | |
<requestedPrivileges> | |
<requestedExecutionLevel | |
level="asInvoker" | |
uiAccess="false" | |
/> | |
</requestedPrivileges> | |
</security> | |
</trustInfo> | |
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> | |
<application> | |
<!-- Windows 10 --> | |
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/> | |
<!-- Windows 8.1 --> | |
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/> | |
<!-- Windows Vista --> | |
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> | |
<!-- Windows 7 --> | |
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/> | |
<!-- Windows 8 --> | |
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/> | |
</application> | |
</compatibility> | |
</assembly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GetVersionEx.exe: GetVersionEx.c | |
i686-w64-mingw32-gcc -o GetVersionEx.exe GetVersionEx.c -static -s -municode |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment