| 338 | } |
| 339 | |
| 340 | void version_win(version_t *v) |
| 341 | { |
| 342 | memset(v, 0, sizeof(version_t)); |
| 343 | |
| 344 | HANDLE h = GetModuleHandleA("kernel32.dll"); |
| 345 | if(h) |
| 346 | { |
| 347 | GetVersionFunc GetVersionPtr = (GetVersionFunc)GetProcAddress(h, "GetVersion"); |
| 348 | DWORD dwVersion = 0; |
| 349 | |
| 350 | if(GetVersionPtr != NULL) |
| 351 | { |
| 352 | dwVersion = GetVersionPtr(); |
| 353 | v->major = (int)(LOBYTE(LOWORD(dwVersion))); |
| 354 | v->minor = (int)(HIBYTE(LOWORD(dwVersion))); |
| 355 | |
| 356 | if (dwVersion < 0x80000000) |
| 357 | { |
| 358 | v->build = (int)(HIWORD(dwVersion)); |
| 359 | } |
| 360 | |
| 361 | if(v->major == 4 && !version_is_nt()) |
| 362 | { |
| 363 | version_t vreg; |
| 364 | static char vbuf[32]; |
| 365 | if(registryRead("HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\VersionNumber", vbuf, sizeof(vbuf))) |
| 366 | { |
| 367 | version_parse(vbuf, &vreg); |
| 368 | if(vreg.major == v->major |
| 369 | && vreg.minor == v->minor) |
| 370 | { |
| 371 | v->patch = vreg.patch; |
| 372 | } |
| 373 | } |
| 374 | } |
| 375 | |
| 376 | return; |
| 377 | } |
| 378 | } |
| 379 | |
| 380 | /* windows >= 8.1 doesn't have this GetVersion */ |
| 381 | v->major = 8; |
| 382 | v->minor = 1; |
| 383 | } |
| 384 | |
| 385 | /* |
| 386 | * NT function tip from: https://stackoverflow.com/a/57130 |
no test coverage detected