BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

What is my version number?

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical)
View previous topic :: View next topic  
Author Message
José
Guest





PostPosted: Sat May 12, 2007 9:25 pm    Post subject: What is my version number? Reply with 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?
--
José
Back to top
JF Jolin
Guest





PostPosted: Sat May 12, 2007 11:46 pm    Post subject: Re: What is my version number? Reply with quote



GetFileVersionInfo
Back to top
José
Guest





PostPosted: Sun May 13, 2007 1:00 am    Post subject: Re: What is my version number? Reply with quote



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





PostPosted: Sun May 13, 2007 6:32 am    Post subject: Re: What is my version number? Reply with quote

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





PostPosted: Mon May 14, 2007 2:24 pm    Post subject: CodeGear Gunning For Enterprise Ruby on Rails Reply with quote

http://www.internetnews.com/dev-news/article.php/3677331

Richard
Back to top
Colin B Maharaj
Guest





PostPosted: Wed May 16, 2007 6:40 am    Post subject: Re: What is my version number? Reply with quote

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
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Non-Technical) All times are GMT
Page 1 of 1

 
Jump to:  
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


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.