Autor Beitrag
luckyluke84
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

WinXP
Lazarus
BeitragVerfasst: So 01.08.04 18:41 
Hi Community !

Ich weiß zwar nicht ob ich hier richtig bin,
hoffe dennoch das mir geholfen werden kann.

Ich suche eine Möglichkeit die
Major, Minor, Release und Build-Eigenschaften
auszulesen.

application.Major oder sowas existiert ja nicht.


Danke im Voraus


Moderiert von user profile iconTino: Topic aus CLX / Delphi Language (Object-Pascal) verschoben am Do 03.03.2005 um 14:49
Motzi
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 2931

XP Prof, Vista Business
D6, D2k5-D2k7 je Prof
BeitragVerfasst: So 01.08.04 22:55 
Einfach mal aus meinem X-Spy rauskopiert...
ausblenden volle Höhe Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
type
  TVersionInfo = packed record
    Major   : Word;
    Minor   : Word;
    Release : Word;
    Build   : Word;
  end;

{=== GetFileVersion ============================================================
  Author  : Motzi
  Date    : unknown

  Purpose : Ermittelt die Versionsnummer des Programms
===============================================================================}

function GetFileVersion(const aFileName : String; pProductVersion: PString): TVersionInfo;
var
  dwVersionSize   : DWord;
  dwDummy         : DWord;
  pVerBuf         : Pointer;
  pFixBuf         : PVSFixedFileInfo;
  pVarFInfo       : PChar;
  dwVarFInfo      : DWord;
  dwVarTrans      : DWord;
  aVarFPath: array [0..MAX_PATH] of Char;
begin
  ZeroMemory(@Result, SizeOf(Result));
  dwDummy := 0;

  dwVersionSize := GetFileVersionInfoSize(Pointer(aFileName), dwDummy);
  if dwVersionSize > 0 then
  begin
    pVerBuf := GetMemory(dwVersionSize);
    try
      if GetFileVersionInfo(Pointer(aFileName), 0, dwVersionSize, pVerBuf) then
      begin
        if VerQueryValue(pVerBuf, '\', Pointer(pFixBuf), dwDummy) then
        begin
          Result.Major   := pFixBuf^.dwFileVersionMS and $FFFF0000 shr 16;
          Result.Minor   := pFixBuf^.dwFileVersionMS and $0000FFFF;
          Result.Release := pFixBuf^.dwFileVersionLS and $FFFF0000 shr 16;
          Result.Build   := pFixBuf^.dwFileVersionLS and $0000FFFF;
        end;

        if pProductVersion <> nil then
        begin
          pVarFInfo := nil;
          dwVarFInfo := 0;
          if VerQueryValue(pVerBuf, '\VarFileInfo\Translation', Pointer(pVarFInfo), dwVarFInfo) then
          begin
            dwVarTrans := HiWord(PDWORD(pVarFInfo)^) or (Word(PDWORD(pVarFInfo)^) shl 16);
            wvsprintf(aVarFPath, '\StringFileInfo\%8.8x\', PChar(@dwVarTrans));
            lstrcat(aVarFPath, 'ProductVersion');
            pVarFInfo := nil;
            dwVarFInfo := 0;
            if VerQueryValue(pVerBuf, aVarFPath, Pointer(pVarFInfo), dwVarFInfo) then
              pProductVersion^ := pVarFInfo;
          end;
        end;
      end;
    finally
      FreeMemory(pVerBuf);
    end;
  end;
end;

_________________
gringo pussy cats - eef i see you i will pull your tail out by eets roots!
luckyluke84 Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 54

WinXP
Lazarus
BeitragVerfasst: So 01.08.04 23:59 
Danke für die Hilfe. Aber nur kopieren wäre zu einfach.
Wie groß ist die Konstante MAX_PATH?
Ich hab sie einfach mal auf 255 gesetzt!
Was genau beinhaltet der Typ : PVSFixedFileInfo

Und beim Kompilieren hält er immer bei
Undeclared Identifer :
GetFileVersionInfoSize
GetFileVersionInfo
VerQueryValue
wvsprintf
lstrcat
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mo 02.08.04 01:03 
Unit Windows.pas eingebunden?
TimonWorld
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Mi 02.03.05 21:27 
Und wie benutzt man die Funktion?

Was soll ich jetzt machen, damit ich Build oder ähnliches in einen String kriege vom aktuellem Programm?

Gruß,
Timon
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Mi 02.03.05 22:06 
TimonWorld hat folgendes geschrieben:
Und wie benutzt man die Funktion?

Einfach aufrufen.

Zitat:

Was soll ich jetzt machen, damit ich Build oder ähnliches in einen String kriege vom aktuellem Programm?

Wenn du dir das ganze mal richtig angeguckt hättest, dann würdest du sehen dass die Funktion einen TVersionInfo Record zurückgibt. Dessen einzelde Felder kann man dann irgendwie weiterverarbeiten.
TimonWorld
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 397



BeitragVerfasst: Mi 02.03.05 22:48 
sorry... hab noch nie mit records gearbeitet :oops: :lol:

gruß,
timon
MathiasSimmack
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Do 03.03.05 15:39 
Ich finde das zwar nicht zum Lachen, aber um die Sache abzukürzen: Suche in: Delphi-Forum, Delphi-Library GETFILEINFO, oder noch spezieller: hier.
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Fr 04.03.05 15:11 
aber das datum der kompilierung bekommt man so nicht raus oder ?

_________________
In the beginning was the word.
And the word was content-type: text/plain.
Luckie
Ehemaliges Mitglied
Erhaltene Danke: 1



BeitragVerfasst: Fr 04.03.05 15:24 
matze hat folgendes geschrieben:
aber das datum der kompilierung bekommt man so nicht raus oder ?

Doch: www.luckie-online.de...geLinkTimeStamp.html
matze
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 4613
Erhaltene Danke: 24

XP home, prof
Delphi 2009 Prof,
BeitragVerfasst: Sa 05.03.05 10:05 
DU BIST MEIN HELD ! :wink: danke

_________________
In the beginning was the word.
And the word was content-type: text/plain.