Jump to content


This is a ready-only archive of the InstallSite Forum. You cannot post any new content here. / Dies ist ein Archiv des InstallSite Forums. Hier können keine neuen Beiträge veröffentlicht werden.
Photo

Brauche Zusätzliche Versionsinformationen


4 replies to this topic

harkan

harkan
  • Full Members
  • 6 posts

Posted 18 March 2005 - 13:53

Hallo!

Ich bin schon überall am suchen und werde nicht fündig:

Ich muss die "File Version" und "Product Version" einer *.exe-Datei in InstallScript abfragen, jedoch nicht wie mit "VerFindFileVersion()". Ich benötige die zusätzlichen Versionen, die man selbst vergeben kann (other file versions). Mit "<major version>.<minor version>" kann ich also nicht viel anfangen.

Wie kann ich über InstallScript diese Versionen abfragen?

Wie kann ich folgende Funktionen der Windows API in InstallScript verwenden?

- GetFileVersionInfo
- VerQueryValue
- GetFileVersionInfoSize

Habe Probleme, in InstallScript die Datentypen richtig zu verwenden.

Bitte dringend um Hilfe.

Vielen Dank.
Harkan


P.S. Ich verwende InstallShield Developer 7

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 21 March 2005 - 09:22

Vielleicht hilft das Beispiel "Read ProductVersion from File" unter http://www.installsi...en/isp_comp.htm

harkan

harkan
  • Full Members
  • 6 posts

Posted 21 March 2005 - 10:25

Danke für die Antwort.
Ich habe das Beispiel inzwischen auch gefunden.
Problem hierbei ist nur, dass die VS_FIXEDFILEINFO Struktur benutzt wird (also nicht die additional Informations wie Comments, ProductName, PrivateBuild, usw.).

Ich habe das Beispiel auch schon etwas hingebogen.
Allerdings fehlt noch der letzte Schliff.
Ich kann bis jetzt nicht den Pointer in einen String umwandeln.

Als fiiaddr bekomme ich einen Pointer.
Als fiilen erhalte ich 4. {2.6NULL}
Gibt es noch eine andere Möglichkeit als jetzt jeden CHAR in einen String zu verwandeln? Siehe Ansatz Kommentar???


CODE

// #################
// DEFINES
// #################

// for backward compatibility with IS5
#if _ISCRIPT_VER < 0x600
#define cdecl
#define BYVAL
#endif

#define MAX_BUF 65535

// #################
// TYPES
// #################
typedef VS_FIXEDFILEINFO
begin
 LONG dwSignature;
 LONG dwStrucVersion;         //  e.g. 0x00000042 = "0.42"
 LONG dwFileVersionMS;        //  e.g. 0x00030075 = "3.75"
 LONG dwFileVersionLS;        //  e.g. 0x00000031 = "0.31"
 LONG dwProductVersionMS;     //  e.g. 0x00030010 = "3.10"
 LONG dwProductVersionLS;     //  e.g. 0x00000031 = "0.31"
 LONG dwFileFlagsMask;        //  = 0x3F for version "0.42"
 LONG dwFileFlags;            //  e.g. VFF_DEBUG Or VFF_PRERELEASE
 LONG dwFileOS;               //  e.g. VOS_DOS_WINDOWS16
 LONG dwFileType;             //  e.g. VFT_DRIVER
 LONG dwFileSubtype;          //  e.g. VFT2_DRV_KEYBOARD
 LONG dwFileDateMS;           //  e.g. 0
 LONG dwFileDateLS;           //  e.g. 0  
end;



// #################
// Windows API calls
// #################
// BYREF and BYVAL added to STRING args to eliminate compilation warnings
prototype Version.GetFileVersionInfoSizeA(BYREF STRING, BYREF LONG);
prototype Version.GetFileVersionInfoA(BYREF STRING, LONG, LONG, POINTER);
prototype Version.VerQueryValueA(POINTER, BYVAL STRING, BYREF LONG, BYREF LONG);
// Added return values.
// Malloc was being passed a POINTER rather than a LONG.
// cdecl calling convention must be specified.
prototype cdecl POINTER Msvcrt.memcpy(POINTER, POINTER, BYVAL LONG);
prototype cdecl POINTER Msvcrt.malloc(BYREF LONG);
prototype cdecl Msvcrt.free(POINTER);    


// #################
// PROTOTYPES
// #################
prototype VerGetProductVersion(STRING, BYREF STRING);
prototype CalcVersion(LONG, BYREF STRING);
prototype NUMBER CalcHighWord(LONG, BYREF STRING);
prototype NUMBER CalcLowWord(LONG, BYREF STRING);

///////////////////////////////////////////////////////////////////////////////
//
// Function: VerGetProductVersion
//
//  Purpose: This function reads the Product Version (instead of the File
//           Version, which is what VerGetFileVersion() returns).
//
///////////////////////////////////////////////////////////////////////////////
function VerGetProductVersion(sFile, sProductVersion)
LONG fressize, freshnd, fiiaddr, fiilen, ret;
POINTER verbuf;          
LONG    lMaxBuf;
STRING  szLanguage, szCode;
NUMBER nCodePage, nLanguage;
STRING szProductVersion;
STRING szCommand;
CHAR chBuffer;
LONG lLangCodePage; /*2 dword values for language and codepage*/
begin

 UseDLL(WINSYSDIR ^ "Version.dll");
 UseDLL(WINSYSDIR ^ "msvcrt.dll");  
                         
 //
 // MAX_BUF must now be passed to malloc as a variable.
 //
 lMaxBuf   = MAX_BUF;
 // get memory chunk
 verbuf = malloc(lMaxBuf);    
 if (verbuf != 0) then
   // Determine if version information is present, and
   // if so how large a buffer is needed to hold it.
   fressize = GetFileVersionInfoSizeA(sFile, freshnd);

   // Version info is unlikely to ever be greater than MAX_BUF
   // but check anyway. If it was larger than MAX_BUF, we would
   // need to allocate a huge buffer instead.  Note, we
   // are only using an approximation to MAX_BUF here to take
   // into account the InstallShield string overhead.
   if (fressize > MAX_BUF) then
     fressize = MAX_BUF;
   endif;
   
   // Load the string with the version information
   ret = GetFileVersionInfoA(sFile, freshnd, fressize, verbuf);
   
if (ret > 0) then
     // Copy the fixed file info into the structure            
     ret = VerQueryValueA(verbuf, "\\VarFileInfo\\Translation", fiiaddr, fiilen);    
     if (ret > 0) then
       memcpy(&lLangCodePage,fiiaddr, fiilen);
       nLanguage = CalcLowWord(lLangCodePage, szLanguage);
       nCodePage = CalcHighWord(lLangCodePage, szCode);
       szCommand = "\\StringFileInfo\\" + szLanguage + szCode + "\\ProductVersion";
       ret = VerQueryValueA(verbuf, szCommand, fiiaddr, fiilen);
       if (ret > 0) then
     // HIER MUSS DER STRING KONVERTIERT WERDEN !!!
           /*memcpy(&chBuffer, fiiaddr, 1);
           chBuffer = chBuffer;
           memcpy(&chBuffer, fiiaddr+1, 1);
           chBuffer = chBuffer;
           memcpy(&chBuffer, fiiaddr+2, 1);
           chBuffer = chBuffer;
           memcpy(&chBuffer, fiiaddr+3, 1);
           chBuffer = chBuffer;*/
       endif;
     endif;  
   endif;

   // Now free the allocated memory.
   free(verbuf);
 endif;

 UnUseDLL(WINSYSDIR ^ "msvcrt.dll");
 UnUseDLL(WINSYSDIR ^ "Version.dll");  
 

end;

function NUMBER CalcHighWord(lComplete, szVal)
NUMBER buffer;
begin
buffer = lComplete >> 16;
buffer = buffer & 0xffff;
    Sprintf (szVal, "%04lX", buffer);
    return buffer;
end;


function NUMBER CalcLowWord(lComplete, szVal)
NUMBER buffer;
begin
buffer = lComplete & 0xffff;
Sprintf (szVal, "%04lX", buffer);
    return buffer;
end;



Vielen Dank soweit.

Gruß Harkan



harkan

harkan
  • Full Members
  • 6 posts

Posted 21 March 2005 - 11:42


Ok ich hab ne Lösung gefunden.

Die Funktion PointerToStr(BYREF STRING, POINTER).
http://www.installsi.../en/isp_ext.htm
(könnte allerdings auch unter Strings stehen)

Interessant wäre, ob das mit InstallShield Developer 7
nicht etwas eleganter ginge.

Danke für alles.
Grüße Harkan

Stefan Krueger

Stefan Krueger

    InstallSite.org

  • Administrators
  • 13,269 posts

Posted 22 March 2005 - 18:05

QUOTE
(könnte allerdings auch unter Strings stehen)

Da gebe ich dir Recht, ich ändere das. Danke für den Hinweis.