Board index » cppbuilder » Re: version number in ptoject

Re: version number in ptoject


2005-01-19 12:57:17 AM
cppbuilder48
Darío Alejandro Guzik wrote:
Quote
Hi!

Can I access the version number of the project options from the code so
I can show it in a "about" form?
Previously discussed many times:
//---------------------------------------------------------------------------
String __fastcall TForm6::VersionInfo(const String &sQuery)
{
DWORD c;
DWORD dw=0;
UINT ui;
char *p;
LPVOID ptr;
String sOut=ParamStr(0); ///ParamStr(0) holds exe name
c = GetFileVersionInfoSize(ParamStr(0).c_str(), &dw);
p = new char[c + 1]; //file://create the space
GetFileVersionInfo(ParamStr(0).c_str(),0,c,p);//get the version info data
// Extract the language/translation information...
VerQueryValue(p, TEXT("\\VarFileInfo\\Translation"), &ptr, &ui);
// ptr comes back as a ptr to two (16-bit) words containing the two halves of
// the translation number required for StringFileInfo
WORD *id=(WORD*)ptr;
String sBase = String("\\StringFileInfo\\")+
IntToHex(id[0],4) +
IntToHex(id[1],4) +
"\\";
String qs = sBase + sQuery ; // query string
VerQueryValue(p, qs.c_str(), &ptr, &ui);
sOut = (char*)ptr;
delete [] p;
return sOut;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormActivate(TObject *Sender)
{
String Caption=VersionInfo("LegalCopyright");
String ProductName=VersionInfo("ProductName");
String FileVersion=VersionInfo("FileVersion");
:
use as desired...
:
}
//---------------------------------------------------------------------------
 
 

Re:Re: version number in ptoject

thanks.
next time I will search the history
Keith wrote:
Quote

Darío Alejandro Guzik wrote:


>Hi!
>
>Can I access the version number of the project options from the code so
>I can show it in a "about" form?


Previously discussed many times:

//---------------------------------------------------------------------------
String __fastcall TForm6::VersionInfo(const String &sQuery)
{
DWORD c;
DWORD dw=0;
UINT ui;
char *p;
LPVOID ptr;
String sOut=ParamStr(0); ///ParamStr(0) holds exe name
c = GetFileVersionInfoSize(ParamStr(0).c_str(), &dw);
p = new char[c + 1]; //file://create the space
GetFileVersionInfo(ParamStr(0).c_str(),0,c,p);//get the version info data
// Extract the language/translation information...
VerQueryValue(p, TEXT("\\VarFileInfo\\Translation"), &ptr, &ui);
// ptr comes back as a ptr to two (16-bit) words containing the two halves of
// the translation number required for StringFileInfo
WORD *id=(WORD*)ptr;
String sBase = String("\\StringFileInfo\\")+
IntToHex(id[0],4) +
IntToHex(id[1],4) +
"\\";
String qs = sBase + sQuery ; // query string
VerQueryValue(p, qs.c_str(), &ptr, &ui);
sOut = (char*)ptr;
delete [] p;
return sOut;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormActivate(TObject *Sender)
{
String Caption=VersionInfo("LegalCopyright");
String ProductName=VersionInfo("ProductName");
String FileVersion=VersionInfo("FileVersion");
:
use as desired...
:
}
//---------------------------------------------------------------------------



--
Darío Alejandro Guzik (El Tío Borracho)
tioborracho.tripod.com
e-mail: XXXX@XXXXX.COM
ICQ : 8389493
 

Re:Re: version number in ptoject

Keith,
I was also interested in finding and using version number info., so when I
saw your response to Dario, I jumped on it. But I cannot make it work. All
of the GetVersionInfoXXX routines fail (without warning). The only thing
that works is "ParamStr(0)".
"GetVersionInfoSize" returns zero, so I used my own software to find the
file size (~ 1.2 MB).
What does
GetFileVersionInfo(sFilenameExe.c_str(), 0, FileSize, p);
put into the memory pointed to by "p", a copy of the EXE? (I presume that
what it does, since it returns no value.) That can be upwards of 10 MB for
the actual cases where I want to use this software. Is all of that storage
necessary?
I have looked high and low for any online HELP documentation on
GetFileVersionInfo, and I found none.
Then:
VerQueryValue(p, TEXT("\\VarFileInfo\\Translation"), &ptr, &ui);
fails to assign any value to "ptr" (I stuck in "ptr = NULL;" before the call
and it was still NULL upon return). This, of course, results in access
violations later.
Also, no documentation of "LPVOID" (Not that it matters --- lots of usages
in CBuilder5 Examples folder).
Richard
"Keith" < XXXX@XXXXX.COM >wrote in message
Quote


Darío Alejandro Guzik wrote:

>Hi!
>
>Can I access the version number of the project options from the
>code so
>I can show it in a "about" form?

Previously discussed many times:

//---------------------------------------------------------------------------
String __fastcall TForm6::VersionInfo(const String &sQuery)
{
DWORD c;
DWORD dw=0;
UINT ui;
char *p;
LPVOID ptr;
String sOut=ParamStr(0); ///ParamStr(0) holds exe name
c = GetFileVersionInfoSize(ParamStr(0).c_str(), &dw);
p = new char[c + 1]; //file://create the space
GetFileVersionInfo(ParamStr(0).c_str(),0,c,p);//get the version info data
// Extract the language/translation information...
VerQueryValue(p, TEXT("\\VarFileInfo\\Translation"), &ptr, &ui);
// ptr comes back as a ptr to two (16-bit) words containing the two halves
of
// the translation number required for StringFileInfo
WORD *id=(WORD*)ptr;
String sBase = String("\\StringFileInfo\\")+
IntToHex(id[0],4) +
IntToHex(id[1],4) +
"\\";
String qs = sBase + sQuery ; // query string
VerQueryValue(p, qs.c_str(), &ptr, &ui);
sOut = (char*)ptr;
delete [] p;
return sOut;
}
//---------------------------------------------------------------------------
void __fastcall TForm6::FormActivate(TObject *Sender)
{
String Caption=VersionInfo("LegalCopyright");
String ProductName=VersionInfo("ProductName");
String FileVersion=VersionInfo("FileVersion");
:
use as desired...
:
}
//---------------------------------------------------------------------------



 

{smallsort}