 |
BorlandTalk.com Borland discussion newsgroups
|
| View previous topic :: View next topic |
| Author |
Message |
José Guest
|
Posted: Sat May 12, 2007 9:25 pm Post subject: What is my version number? |
|
|
I can set my program's version number in Project | Options
I can read the version number by right clicking on the EXE file and
selecting Properties.
Is there a way for a program to know its own version number?
--
José |
|
| Back to top |
|
 |
JF Jolin Guest
|
Posted: Sat May 12, 2007 11:46 pm Post subject: Re: What is my version number? |
|
|
GetFileVersionInfo |
|
| Back to top |
|
 |
José Guest
|
Posted: Sun May 13, 2007 1:00 am Post subject: Re: What is my version number? |
|
|
On Sat, 12 May 2007 14:46:25 -0400, "JF Jolin" <jfj (AT) nospam (DOT) com> wrote
in borland.public.cppbuilder.non-technical:
| Quote: | GetFileVersionInfo
|
Thanks, that was sufficient.
Whenever you want to do something, the first problem is: what function
to use? When you know the function name, the Help file can tell you
how to use it. In this case the Help file was n't helpful and I had to
search the internet for an example.
It is funny that the function requires the program name. Apparently it
is too stupid to know it. It can be obtained from argv (another
complication since only the main module knows argv), but fortunately
the program name is always the same, while the version number isn't.
--
José |
|
| Back to top |
|
 |
Bob Gonder Guest
|
Posted: Sun May 13, 2007 6:32 am Post subject: Re: What is my version number? |
|
|
José wrote:
| Quote: | It is funny that the function requires the program name. Apparently it
is too stupid to know it. It can be obtained from argv (another
complication since only the main module knows argv),
|
No, it is generic. It can find the version for _other_ files, not just
the one that is currently running.
| Quote: | but fortunately
the program name is always the same, while the version number isn't.
|
Ahh, but the user can change the file name.
You might be better using GetModuleFileName() to get the actual file
name. |
|
| Back to top |
|
 |
Richard Kavanagh Guest
|
|
| Back to top |
|
 |
Colin B Maharaj Guest
|
Posted: Wed May 16, 2007 6:40 am Post subject: Re: What is my version number? |
|
|
José wrote:
| Quote: | I can set my program's version number in Project | Options
I can read the version number by right clicking on the EXE file and
selecting Properties.
Is there a way for a program to know its own version number?
|
try this.........
Fn should be ParamStr(0); to get the current file version.
AnsiString BuildString(System::AnsiString Fn)
{
DWORD Handle;
DWORD Size;
bool error = false;
void *pBuffer;
AnsiString ret;
Size = GetFileVersionInfoSize(Fn.c_str(), &Handle);
if (Size)
{
pBuffer = new char [Size];
if (GetFileVersionInfo(Fn.c_str(),Handle, Size,pBuffer))
{
struct TRANSLATION { WORD langID; WORD charset; } translation;
VS_FIXEDFILEINFO * lpvi;
UINT iLen;
int n = VerQueryValue(pBuffer, "\\VarFileInfo\\Translation",
(void **)&lpvi, &iLen);
if (n != 0)
{
translation = *(TRANSLATION*)lpvi;
char szName[512];
wsprintf(szName, "\\StringFileInfo\\%04x%04x\\FileVersion",
translation.langID, translation.charset);
unsigned int buflen;
char *b;
if (VerQueryValue((LPVOID)pBuffer, szName, (void **)&b,&buflen))
{
ret = (AnsiString) b;
}
}
else error = true;
}
else error = true;
delete[] pBuffer;
}
else error = true;
if (error) ret = "N/A";
return ret;
} |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|