⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 read.cgi-read=10399.htm

📁 随书类文件![随书类]MFC_SOURCEBOOK
💻 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 &amp; 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 &lt;garpajian@rigel.east.dialog.com&gt; wrote in article &lt;01bc0a5c$9bf38cb0$b36950c6@garpajian&gt;...
<BR>&gt; Can anyone provide sample code on how to get the version information
<BR>&gt; found in the Version Resources.  I need information such as  Company
<BR>&gt; 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 = &quot;Version %d.%d%d (Build %d)&quot;
<P>#ifdef	_DEBUG
<BR>    	sVersion.Format (sTemp + &quot;-Debug&quot;, 
<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 &quot;winver.h&quot;
<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 &quot;StringFileInfo&quot;
<BR>//     		BEGIN
<BR>//     			BLOCK &quot;040904b0&quot;		(this is for ENGLISH LANGUAGE)
<BR>//     			BEGIN
<BR>//					:
<BR>//     				VALUE &quot;Author&quot;, &quot;Written by John Young\0&quot;
<BR>//     				VALUE &quot;FileDescription&quot;, &quot;Some cool utility\0&quot;
<BR>//     				VALUE &quot;InternalName&quot;, &quot;CoolUtility\0&quot;
<BR>//     				VALUE &quot;LegalCopyright&quot;, &quot;Copyright 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -