How i can insert in a simple form a version and build of my program
inserted in exe file with the project option and visible only with
proprierty of file in the explorer ?
Thanks in advanced.
Source code is included.
Thanks,
--
===========================================
Imran Hussain
MCP, MCSD
imr...@imranweb.com
http://www.imranweb.com
===========================================
void __fastcall TAboutBoxForm::FormCreate(TObject *Sender)
{
DWORD dwResulut;
bool bResult;
unsigned int uiResulut;
DWORD EmptyHandle;
void* VersionData;
char* Version;
char* Build;
try
{
dwResulut = GetFileVersionInfoSize(Application->ExeName.c_str(),
&EmptyHandle);
VersionData = new BYTE [dwResulut];
bResult = GetFileVersionInfo(Application->ExeName.c_str(), 0,
dwResulut, VersionData);
if(!bResult)
{
delete VersionData;
return;
}
VerQueryValue(VersionData,
TEXT("\\StringFileInfo\\040904E4\\FileVersion"), (void**)&Build,
&uiResulut);
BuildNumberText->Caption = Build;
VersionNumberText->Caption = Version;
}
catch (...)
{
delete VersionData;
}
delete VersionData;
}
Where BuildNumberText and VersionNumberText are TLabels.
Gambit
Massimo wrote in message <70itmd$f1...@forums.borland.com>...
1. Go to Projects/Options menu (Shift-Ctrl-F11)
2. Select Version info tab
3. Check 'Include version information in project' check box
4. Set the values
and voila
What version of Builder? If it's 3.0, just set it in the project options.
It's a simple resource. :-)
----------------------------------------------------------------------------
David J. Fenwick d...@assetsw.com
Nomadic Developer Asset Software, Inc.
Proud Member of Inprise's TeamB
"We'll do anything if you don't pay us."
I think he wanted to know how to retrieve the information, not how
to set it. :)
Here is some barely-tested code, but it appears to work. MS help for
VerQueryValue does not specify who is responsible for deleting the
data that it returns through the provided pointer, and I don't delete
it so there may be a leak. But even if there is, your TAbout form can
be autocreated and thus only leak one time harmlessly. If it is
dynamically created, then it'll leak every time someone call
Help|About, but even then it probably won't happen enough to cause
much harm.
Anybody know if I'm supposed to delete the buffer returned from
VerQueryValue, or does the OS miraculously manage it for me, since it
allocated it? My guess is that it does not need deleting, as it
probably points to the memory image of the string resource directly.
Hope this helps, Massimo.
bool
GetBuildVersionNumbers(String *buildstr, String *versionstr)
{
bool retval = false;
if (!buildstr || !versionstr)
return retval;
DWORD size;
bool success;
void* data;
try
{
DWORD ignored;
size =
GetFileVersionInfoSize(Application->ExeName.c_str(),&ignored);
data = new BYTE [size];
success = GetFileVersionInfo(Application->ExeName.c_str(), 0,
size, data);
if(success)
{
size_t build_size, version_size;
char* build;
char* version;
VerQueryValue(data,
TEXT("\\StringFileInfo\\040904E4\\FileVersion"),
(void**)&build,
&build_size);
VerQueryValue(data,
TEXT("\\StringFileInfo\\040904E4\\ProductVersion"),
(void**)&version,
&version_size);
if (version_size)
*versionstr = version;
if (build_size)
*buildstr = build;
retval = true;
}
}
__finally
{
delete [] data;
}
return retval;
}
//---------------------------------------------------------------------
void __fastcall TAbout::FormCreate(TObject *Sender)
{
String build, version;
if (GetBuildVersionNumbers(&build, &version))
BuildLabel->Caption = String("Version: ") + build;
else
BuildLabel->Caption = "Version: Unknown";
}
//---------------------------------------------------------------------
--
Chris (TeamB)
I don't think so. Reread the original post. I think he wants to see the
file information when he right clicks on it in Explorer and selects
"Properties". That's how I read it. :-)
> I don't think so. Reread the original post. I think he wants to see the
> file information when he right clicks on it in Explorer and selects
> "Properties". That's how I read it. :-)
I did reread it and I still think the same way. :) He says he wants
to insert the version and build into a simple form. The part about it
being visible in the explorer is to just define the numbers about
which he's speaking. I think. :)
How i can insert in a simple form a version and build
of my program inserted in exe file with the project
option and visible only with proprierty of file in
the explorer ?
OK, Massimo, which way is it? Settle this for us... <grin>
--
Chris (TeamB)
TASTES GREAT!