I made a console application and want to write OS name and version in the title. But the ways I tried did not work.
Firstly I tried a code I saw on Microsoft documents: But it did not work and I got error called "C4996" (GetVersion() declared deprecated)
DWORD dwVersion = 0;
DWORD dwMajorVersion = 0;
DWORD dwMinorVersion = 0;
DWORD dwBuild = 0;
dwVersion = ::GetVersion();
dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
dwMinorVersion = (DWORD)(HIBYTE(LOWORD(dwVersion)));
if (dwVersion < 0x80000000)
dwBuild = (DWORD)(HIWORD(dwVersion));
After that I tried to use GetVersionExW() but it did not work either and deprecated too.
void GetOSVersion_Normal()
{
OSVERSIONINFOEX versioninfo;
versioninfo.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
if (::GetVersionExW((LPOSVERSIONINFO)&versioninfo))
{
printf("MajorVersion : %d , MinorVersion : %d, ProductType : %d, ServicePack : %d.%d\n", versioninfo.dwMajorVersion, versioninfo.dwMinorVersion, versioninfo.wProductType, versioninfo.wServicePackMajor, versioninfo.wServicePackMinor);
printf("\nMeaning of product type\n");
printf("0 - UNKNOWN\n1 - VER_NT_WORKSTATION\n2 - VER_NT_DOMAIN_CONTROLLER\n3 - VER_NT_SERVER\n");
}
}
I tried to use #pragma to ignore warnings but it did not work.
Now Im sadly writing here :c