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 |
634 |
memset (&pi, 0, sizeof (pi)); |
memset (&pi, 0, sizeof (pi)); |
635 |
//hh.exe -mapid 40 "winpt.$lang.chm" |
//hh.exe -mapid 40 "winpt.$lang.chm" |
636 |
|
|
637 |
_snprintf (path, 2*MAX_PATH, "hh.exe -mapid %d winpt.%s.chm", |
_snprintf (path, 2*MAX_PATH, "hh.exe -mapid %d winpt.%s.chm", map_id, gettext_get_langid ()); |
638 |
map_id, gettext_get_langid ()); |
CreateProcess (NULL, path, &sec_attr, &sec_attr, FALSE, 0, NULL, NULL, &si, &pi); |
|
CreateProcess (NULL, path, &sec_attr, &sec_attr, |
|
|
FALSE, 0, NULL, NULL, &si, &pi); |
|
639 |
CloseHandle (pi.hProcess); |
CloseHandle (pi.hProcess); |
640 |
CloseHandle (pi.hThread); |
CloseHandle (pi.hThread); |
641 |
return 0; |
return 0; |
654 |
BOOL admin = FALSE; |
BOOL admin = FALSE; |
655 |
PSID psid = 0; |
PSID psid = 0; |
656 |
|
|
|
if (GetVersion () & 0x80000000) /* Win9X */ |
|
|
return TRUE; |
|
|
|
|
657 |
if (!OpenThreadToken (GetCurrentThread (), TOKEN_QUERY, FALSE, &hd) && |
if (!OpenThreadToken (GetCurrentThread (), TOKEN_QUERY, FALSE, &hd) && |
658 |
!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hd)) |
!OpenProcessToken (GetCurrentProcess (), TOKEN_QUERY, &hd)) |
659 |
return FALSE; |
return FALSE; |
664 |
if (!ptg) |
if (!ptg) |
665 |
return FALSE; |
return FALSE; |
666 |
|
|
667 |
if (!GetTokenInformation (hd, TokenGroups, |
if (!GetTokenInformation (hd, TokenGroups, ptg, ngtoken, &ngtoken)) { |
|
ptg, ngtoken, &ngtoken)) { |
|
668 |
GlobalFree (ptg); |
GlobalFree (ptg); |
669 |
return FALSE; |
return FALSE; |
670 |
} |
} |