Board index » delphi » Program Version Info

Program Version Info

I've downloaded and installed TVersionInfo, and placed a component on a
form.

It's not apparent how to get the desired information. I tried to show it on
a label with:

  versioninfo1.Execute('MyApp.exe');
  Label3.caption := versioninfo1.productversion;

where MyApp.exe is the executable file that includes the form with label3.
The label shows:

"1.0.0.0"

while the info shown under Project | Version Info is much different.

Can someone please tell me the right way to use this component?

 

Re:Program Version Info


Why would you choose to use this component in a version of Delphi that
provides version-info handling within the IDE?

Quote
Bob Richardson wrote:

> I've downloaded and installed TVersionInfo, and placed a component on a
> form.

> It's not apparent how to get the desired information. I tried to show it on
> a label with:

>   versioninfo1.Execute('MyApp.exe');
>   Label3.caption := versioninfo1.productversion;

> where MyApp.exe is the executable file that includes the form with label3.
> The label shows:

> "1.0.0.0"

> while the info shown under Project | Version Info is much different.

> Can someone please tell me the right way to use this component?

----------------------------------------------------------------
Sundial Services :: Scottsdale, AZ (USA) :: (480) 946-8259
mailto:i...@sundialservices.com  (PGP public key available.)

- Show quoted text -

Quote
> Fast(!), automatic table-repair with two clicks of the mouse!
> ChimneySweep(R):  Release 4.0 is here!!
> http://www.sundialservices.com/products/chimneysweep

Re:Program Version Info


Quote
On Mon, 11 Feb 2002 15:23:47 -0800, Tony wrote:

To pick up the version assigned in the DElphi IDE you want FileVersion
not ProductVersion.
Quote
>I've downloaded and installed TVersionInfo, and placed a component on a
>form.

>It's not apparent how to get the desired information. I tried to show it on
>a label with:

>  versioninfo1.Execute('MyApp.exe');
>  Label3.caption := versioninfo1.productversion;

>where MyApp.exe is the executable file that includes the form with label3.
>The label shows:

>"1.0.0.0"

>while the info shown under Project | Version Info is much different.

>Can someone please tell me the right way to use this component?

Re:Program Version Info


Quote
"Sundial Services" <info_...@sundialservices.com> wrote in message

news:3C687141.7AA@sundialservices.com...

Quote
> Why would you choose to use this component in a version of Delphi that
> provides version-info handling within the IDE?

I only reason I chose the TVersionInfo component is because I knew of no
other way.  I haven't been successful in my search for info on D5's
version-info handler. Please point me in the right direction. Thanks.

Re:Program Version Info


I'm the one who put TVersionInfo into the FAQ examples page, so I guess I
get to answer this question.  I put it there because it was donated as a
method of accessing the data on the Version Info tab at runtime, when
someone asked how to do this a couple of months ago.  It's a convenient
wrapper.

In article <3C687141....@sundialservices.com>,

Quote
info_...@sundialservices.com wrote:
>Why would you choose to use this component in a version of Delphi that
>provides version-info handling within the IDE?

>Bob Richardson wrote:

>> I've downloaded and installed TVersionInfo, and placed a component on a
>> form.

>> It's not apparent how to get the desired information. I tried to show it on
>> a label with:

>>   versioninfo1.Execute('MyApp.exe');
>>   Label3.caption := versioninfo1.productversion;

>> where MyApp.exe is the executable file that includes the form with label3.
>> The label shows:

>> "1.0.0.0"

>> while the info shown under Project | Version Info is much different.

>> Can someone please tell me the right way to use this component?

--
Esther Michaels
Please respond to newsgroup; I don't check my mail account

Re:Program Version Info


In article <u6gkk3leh8a...@corp.supernews.com>, "Bob Richardson"

Quote
<b...@pleasenospam.whidbey.com> wrote:
>I've downloaded and installed TVersionInfo, and placed a component on a
>form.

>It's not apparent how to get the desired information. I tried to show it on
>a label with:

>  versioninfo1.Execute('MyApp.exe');
>  Label3.caption := versioninfo1.productversion;

>where MyApp.exe is the executable file that includes the form with label3.
>The label shows:

>"1.0.0.0"

>while the info shown under Project | Version Info is much different.

>Can someone please tell me the right way to use this component?

My apologies.  The code in the FAQ examples page that purports to be an
example of how to use this component is actually the source of the
component itself.  My bad!
--
Esther Michaels
Please respond to newsgroup; I don't check my mail account

Re:Program Version Info


Hi Bob,

I have a function in a unit (bobutils.pas) that I "use" in all my projects.
Here's something that will help you.

-----------------------------------------------------------------
function   GetAppVersion(const strAppName: String) : string;
var
  GetInfoJunk: DWORD;        //Unused parameter used as place holder in
parameter list
  strVersion: String;        //Version information string
  ptrInfoPointer: Pointer;   //Points to InfoPointer record structure
  ptrTranslation: Pointer;   //Points to Translation record structure
  ptrVersionInfo: Pointer;   //Points to VersionInfo record structure
  VersionInfoSize: UINT;     //Size of
  VerInfoSize: DWORD;        //Size of VersionInfo record structure
  rAppInfo : record strFileVersion,strFileDesc:String; end;
begin
  Result := '';
  try
      //Get actual size of of VersionInfo record structure
    VerInfoSize := GetFileVersionInfoSize(PChar(strAppName), GetInfoJunk);
    if VerInfoSize > 0 then begin            //Insure that we have an actual
size
      GetMem(ptrVersionInfo, VerInfoSize);   //Allocate memory for
VersionInfo record structure
      try
        //Extract Version Information from executable
        GetFileVersionInfo(PChar(strAppName), 0, VerInfoSize,
ptrVersionInfo);
        //Extract pointer to translation record
        VerQueryValue(ptrVersionInfo, PChar('\\VarFileInfo\\Translation'),
ptrTranslation, VersionInfoSize);
        //Format string used to query VersionInfo record structure
        strVersion :=
'\\StringFileInfo\\'+IntToHex(LoWord(LongInt(ptrTranslation^)), 4)+
                   IntToHex(HiWord(LongInt(ptrTranslation^)), 4)+'\\';
        //Query VersionInfo record structure to get full Version info in
M.m.R.B format
        VerQueryValue(ptrVersionInfo, PChar(Format('%s%s',
[strVersion,'FileVersion'])), ptrInfoPointer, VersionInfoSize);
        rAppInfo.strFileVersion := String(PChar(ptrInfoPointer));
        //Convert Version info to string for return
        VerQueryValue(ptrVersionInfo, PChar(Format('%s%s',
[strVersion,'FileDescription'])),ptrInfoPointer, VersionInfoSize);
        rAppInfo.strFileDesc := String(PChar(ptrInfoPointer));
        Result := rAppInfo.strFileVersion;
      finally
        FreeMem(ptrVersionInfo, VerInfoSize);    //Always free memory for
VersionInfo record structure
      end;
 end;
  except
    on E:Exception do
        begin
     Result := '#N/A';
          raise Exception.Create('AppInfo' + #13#10 + E.Message);
        end;
  end;
end;
-----------------------------------------------------------------

You can then use something like:
    Label1.Caption:='version '+GetAppVersion(Application.EXEName);

If you're trying to do this in a DLL, Application.EXEName is not set.  You
can use this code to get the filename of the DLL:

function GetDllPathName: String;
(*
// Name     : GetDLLPathName
// Purpose  : Returns the name of the current DLL or Application
// Date     : 3/5/2001 from comp.lang.pascal.delphi.misc
// Comments :
http://groups.google.com/groups?hl=en&lr=&safe=off&ic=1&th=ddec443f2d...,
              2&seekm=39100cf7.2906713232%40nntpserver.swip.net#p
*)
var
  Path: array[0..MAX_PATH - 1] of Char;
begin
  if IsLibrary then
    SetString(Result, Path, GetModuleFileName(HInstance,Path,SizeOf(Path)))
  else
    Result := Application.ExeName;
end;

Hope this helps!

- Bob -
www.guru.net.nz

Quote
"Bob Richardson" <b...@pleasenospam.whidbey.com> wrote in message

news:u6il4mes9npjeb@corp.supernews.com...
Quote

> "Sundial Services" <info_...@sundialservices.com> wrote in message
> news:3C687141.7AA@sundialservices.com...
> > Why would you choose to use this component in a version of Delphi that
> > provides version-info handling within the IDE?

> I only reason I chose the TVersionInfo component is because I knew of no
> other way.  I haven't been successful in my search for info on D5's
> version-info handler. Please point me in the right direction. Thanks.

Other Threads