/[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 368 by twoaday, Tue Dec 6 13:40:04 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 677  html_help_show (int map_id) Line 634  html_help_show (int map_id)
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;
# Line 699  user_is_admin (void) Line 654  user_is_admin (void)
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;
# Line 712  user_is_admin (void) Line 664  user_is_admin (void)
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          }          }

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

[email protected]
ViewVC Help
Powered by ViewVC 1.1.26