/[winpt]/trunk/Src/wptW32API.cpp
ViewVC logotype

Diff of /trunk/Src/wptW32API.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 328 by twoaday, Fri Sep 25 16:07:38 2009 UTC revision 355 by twoaday, Sat Dec 3 18:59:01 2011 UTC
# Line 493  center_window (HWND child, HWND parent) Line 493  center_window (HWND child, HWND parent)
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
# Line 699  user_is_admin (void) Line 656  user_is_admin (void)
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;
# Line 712  user_is_admin (void) Line 666  user_is_admin (void)
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          }          }

Legend:
Removed from v.328  
changed lines
  Added in v.355

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26