493 |
} |
} |
494 |
|
|
495 |
|
|
|
/* Retrieve the product verion of the given file @fname. |
|
|
Format: MAJOR.MINOR.PATCH1.PATCH2 |
|
|
Return value: 0 on success. */ |
|
|
int |
|
|
get_file_version (const char *fname, |
|
|
WORD *major, WORD *minor, WORD *patch1, WORD *patch2) |
|
|
{ |
|
|
VS_FIXEDFILEINFO *inf; |
|
|
char file[MAX_PATH+1] = {0}; |
|
|
LPVOID buf, data; |
|
|
DWORD arg; |
|
|
DWORD size; |
|
|
UINT qlen; |
|
|
|
|
|
strncpy (file, fname, MAX_PATH); |
|
|
size = GetFileVersionInfoSize (file, &arg); |
|
|
if (!size) |
|
|
return -1; |
|
|
buf = (LPVOID)new char[size]; |
|
|
if (!buf) |
|
|
BUG (NULL); |
|
|
GetFileVersionInfo (file, 0, size, buf); |
|
|
|
|
|
qlen=0; |
|
|
VerQueryValue (buf, (char*)"\\", &data, &qlen); |
|
|
if (!qlen) { |
|
|
delete [](char*)buf; |
|
|
return -1; |
|
|
} |
|
|
inf = (VS_FIXEDFILEINFO*)data; |
|
|
|
|
|
if (major) |
|
|
*major = HIWORD (inf->dwProductVersionMS); |
|
|
if (minor) |
|
|
*minor = LOWORD (inf->dwProductVersionMS); |
|
|
if (patch1) |
|
|
*patch1 = HIWORD (inf->dwProductVersionLS); |
|
|
if (patch2) |
|
|
*patch2 = LOWORD (inf->dwProductVersionLS); |
|
|
|
|
|
delete [](char*)buf; |
|
|
return 0; |
|
|
} |
|
496 |
|
|
497 |
|
|
498 |
/* Return date in a format which complies with the |
/* Return date in a format which complies with the |
656 |
BOOL admin = FALSE; |
BOOL admin = FALSE; |
657 |
PSID psid = 0; |
PSID psid = 0; |
658 |
|
|
|
if (GetVersion () & 0x80000000) /* Win9X */ |
|
|
return TRUE; |
|
|
|
|
659 |
if (!OpenThreadToken (GetCurrentThread (), TOKEN_QUERY, FALSE, &hd) && |
if (!OpenThreadToken (GetCurrentThread (), TOKEN_QUERY, FALSE, &hd) && |
660 |
!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hd)) |
!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hd)) |
661 |
return FALSE; |
return FALSE; |
666 |
if (!ptg) |
if (!ptg) |
667 |
return FALSE; |
return FALSE; |
668 |
|
|
669 |
if (!GetTokenInformation (hd, TokenGroups, |
if (!GetTokenInformation (hd, TokenGroups, ptg, ngtoken, &ngtoken)) { |
|
ptg, ngtoken, &ngtoken)) { |
|
670 |
GlobalFree (ptg); |
GlobalFree (ptg); |
671 |
return FALSE; |
return FALSE; |
672 |
} |
} |