📄 read.cgi-read=10399.htm
字号:
<HTML><HEAD><TITLE>Re: How to get Version Information</TITLE>
</HEAD><BODY background="../fancyhome/back.gif" tppabs="http://www.codeguru.com/fancyhome/back.gif" bgcolor="#FFFFFF">
<table WIDTH="100%"> <tr WIDTH="100%"> <td><table>
<tr><td><img src="../mfc_sourcebook.jpg" tppabs="http://www.codeguru.com/mfc_sourcebook.jpg"
ALT="MFC Programmer's SourceBook" WIDTH="256"
HEIGHT="88"><td></tr>
<tr><td valign="bottom"><font SIZE="+1"
color="#a0a0ff"><b>Discussion Board</b></font></td></tr>
</table></td> <td width="40"></td>
<td align="right" valign="top"><A HREF="http://209.66.99.126/cgi/ads.cgi?advert=myad2"><IMG SRC="../../209.66.99.126/advertise2.gif" tppabs="http://209.66.99.126/advertise2.gif" ALT="" BORDER=2></A><td> </tr> </table> <hr><P ALIGN=CENTER>[ <A HREF="#Responses">Read Responses</A> | <A HREF="#PostResponse">Post a New Response</A> | <A HREF="index.cgi.htm" tppabs="http://www.codeguru.com/mfc_bbs/index.cgi">Return to the Index</A> ]
<A HREF="read.cgi-read=10345.htm" tppabs="http://www.codeguru.com/mfc_bbs/read.cgi?read=10345">Previous in Thread</A><P ALIGN=CENTER><BIG><BIG><BIG><STRONG>Re: How to get Version Information</STRONG></BIG></BIG></BIG>
<P ALIGN=CENTER><EM>Posted by <STRONG><A HREF="mailto:johngm@eatel.net">John Mills</A></STRONG> on <STRONG>4/25/98 10:52a.m.</STRONG>, in response to <A HREF="read.cgi-read=10345.htm" tppabs="http://www.codeguru.com/mfc_bbs/read.cgi?read=10345">How to get Version Information</A>, posted by David Forest on 4/24/98 11:52a.m.</EM></P>
<!-- REMOTE_HOST: 209.62.44.43; REMOTE_ADDR: 209.62.44.43-->
<P>Here's the source code to a class I use for parsing Version resource info. It's nice in that when I need to pull more than just the version (Company, Author, Product & File Version, etc) I already have it. Another neat feature is that you can customize the VersionInfo Resource and add the extra bits to look for into the class.
<P>ReadMe.txt ======= cut here ======
<P>George G. Arpajian <garpajian@rigel.east.dialog.com> wrote in article <01bc0a5c$9bf38cb0$b36950c6@garpajian>...
<BR>> Can anyone provide sample code on how to get the version information
<BR>> found in the Version Resources. I need information such as Company
<BR>> Name, File Version, Private Build, Special Build, etc.
<P>I rolled my own CVersionInfo class for this very purpose. I use it in
<BR>my About dialog box.
<P>In CAboutDlg::InitDialog(), do this...
<P> CVersionInfo verApp;
<BR> CString sVersion;
<P> GetDlgItemText(IDC_VER_FILEVERSION, sTemp);
<BR> // IDC_VER_FILEVERSION = "Version %d.%d%d (Build %d)"
<P>#ifdef _DEBUG
<BR> sVersion.Format (sTemp + "-Debug",
<BR> verApp.GetMajorFileVer(), verApp.GetMinorFileVer(),
<BR> verApp.GetFileRevision(), verApp.GetFileBuildNr());
<BR>#else
<BR> sVersion.Format (sTemp,
<BR> verApp.GetMajorFileVer(), verApp.GetMinorFileVer(),
<BR> verApp.GetFileRevision(), verApp.GetFileBuildNr());
<BR>#endif
<P> SetDlgItemText (IDC_VER_FILEDESCRIPTION, verApp.GetDescription());
<BR> SetDlgItemText (IDC_VER_FILEVERSION, sVersion);
<BR>// SetDlgItemText (IDC_VER_AUTHOR, verApp.GetAuthor());
<BR> SetDlgItemText (IDC_VER_BUILDDATE, verApp.GetBuildDate());
<BR> SetDlgItemText (IDC_VER_COPYRIGHT, verApp.GetCopyright());
<BR> SetDlgItemText (IDC_VER_COMPANY, verApp.GetCompany());
<P>The CVersionInfo class is attached. Let me know if you have any trouble using
<BR>this.
<P>-John
<P>--
<BR>John Young, Yaesu Musen Co., Ltd., Japan.
<BR>If only computers did what you wanted, not what you tell them.
<P>VersionInfo.h ======= cut here ======
<BR>//
<BR>// VersionInfo.h CVersionInfo class
<BR>//
<P>#include "winver.h"
<P>class CVersionInfo
<BR>{
<BR>public:
<BR> CVersionInfo();
<BR> ~CVersionInfo();
<P> int GetMajorFileVer() { return m_nMajorFileVer; }
<BR> int GetMinorFileVer() { return m_nMinorFileVer; }
<BR> int GetFileRevision() { return m_nFileRevision; }
<BR> int GetFileBuildNr() { return m_nFileBuildNr; }
<P> int GetMajorProdVer() { return m_nMajorProdVer; }
<BR> int GetMinorProdVer() { return m_nMinorProdVer; }
<BR> int GetProdRevision() { return m_nProdRevision; }
<BR> int GetProdBuildNr() { return m_nProdBuildNr; }
<P> const char* GetName() { return m_sName; }
<BR> const char* GetDescription() { return m_sDescription; }
<BR> const char* GetAuthor() { return m_sAuthor; }
<BR> const char* GetFileVersion() { return m_sFileVersion; }
<BR> const char* GetProdVersion() { return m_sProdVersion; }
<BR> const char* GetCopyright() { return m_sCopyright; }
<BR> const char* GetBetaBuild() { return m_sBetaBuild; }
<BR> const char* GetBuildDate() { return m_sBuildDate; }
<BR> const char* GetCompany() { return m_sCompanyName; }
<P> static BOOL ExtractVersion (const char* s, int* nMaj, int* nMin,
<BR> int* nRev, int* nBuild);
<P>protected:
<BR> BOOL ExtractVersion(int fWhich);
<P>private:
<BR> CString m_sName;
<BR> CString m_sDescription;
<BR> CString m_sAuthor;
<BR> CString m_sFileVersion;
<BR> CString m_sProdVersion;
<BR> CString m_sCopyright;
<BR> CString m_sBetaBuild;
<BR> CString m_sBuildDate;
<BR> CString m_sCompanyName;
<P> int m_nMajorFileVer;
<BR> int m_nMinorFileVer;
<BR> int m_nFileRevision;
<BR> int m_nFileBuildNr;
<P> int m_nMajorProdVer;
<BR> int m_nMinorProdVer;
<BR> int m_nProdRevision;
<BR> int m_nProdBuildNr;
<BR>};
<P>VersionInfo.cpp ======= cut here ======
<BR>//
<BR>// VersionInfo.cpp CVersionInfo class
<BR>//
<BR>// Written by John Young, 4 September 1996
<BR>//
<BR>// Extracts information from the the VERSIONINFO structure for the app as
<BR>// follows...
<BR>//
<BR>// VS_VERSION_INFO VERSIONINFO
<BR>// :
<BR>// PRODUCTVERSION 1,2,3,1441 // JGM: -or- 1.2.3.1441
<BR>// :
<BR>// BEGIN
<BR>// BLOCK "StringFileInfo"
<BR>// BEGIN
<BR>// BLOCK "040904b0" (this is for ENGLISH LANGUAGE)
<BR>// BEGIN
<BR>// :
<BR>// VALUE "Author", "Written by John Young\0"
<BR>// VALUE "FileDescription", "Some cool utility\0"
<BR>// VALUE "InternalName", "CoolUtility\0"
<BR>// VALUE "LegalCopyright", "Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -