Prev: How to let a CFrameWnd based SDI application start in full screen?
Next: update CDialog region in a user defined message handler
From: David Webber on 15 Jun 2010 17:26 "JCO" <someone(a)somewhere.com> wrote in message news:Oigi3zBDLHA.2012(a)TK2MSFTNGP02.phx.gbl... > I think I'm missing something but I'm interested in this topic. > If you have your version defined in a header file, then you can display it > in the dialog, however, if you did a "property" on the exe file, has it > really changed? If so, then I got lost somewhere in this thread. #define VERMAX 3 causes VERMAX to be replaced by 3 before compilation of the exe, so of course it is the same in the "property" dialoge. > I was under the impression that you can set something in VS that allowed > the version to change each time you do a build. I don't remember how to > do this but I always thought this was possible. Now it may only change > the Build number and not anything else, however, this is a good feature. > Is this still possible, if so .... how do you do it? Haven't tried it. I only update my build number when making it available to 3rd parties, and I do that manually. It's good enough for my purposes. Dave -- David Webber Mozart Music Software http://www.mozart.co.uk For discussion and support see http://www.mozart.co.uk/mozartists/mailinglist.htm
From: David Webber on 15 Jun 2010 17:29 "JCO" <someone(a)somewhere.com> wrote in message news:#cDkO#KDLHA.2012(a)TK2MSFTNGP02.phx.gbl... > When I add this information to the RC2 file, I get these two errors: > 1 CVT1100: duplicate resource, Type:VERSION, name:1, language:0x0409 > 2 LNK1123: failure during conversion to COFF: file invalid or corrupt If you left the VERSIONINFO in the rc file AND pasted in the rc2 file, then you have it twice. That might be what error 1 is telling you. Dave -- David Webber Mozart Music Software http://www.mozart.co.uk For discussion and support see http://www.mozart.co.uk/mozartists/mailinglist.htm
From: JCO on 15 Jun 2010 19:03 Agreed! "David Webber" <dave(a)musical-dot-demon-dot-co.uk> wrote in message news:O#VF20NDLHA.4400(a)TK2MSFTNGP05.phx.gbl... > > > "JCO" <someone(a)somewhere.com> wrote in message > news:Oigi3zBDLHA.2012(a)TK2MSFTNGP02.phx.gbl... > >> I think I'm missing something but I'm interested in this topic. >> If you have your version defined in a header file, then you can display >> it in the dialog, however, if you did a "property" on the exe file, has >> it really changed? If so, then I got lost somewhere in this thread. > > #define VERMAX 3 > > causes VERMAX to be replaced by 3 before compilation of the exe, so of > course it is the same in the "property" dialoge. > >> I was under the impression that you can set something in VS that allowed >> the version to change each time you do a build. I don't remember how to >> do this but I always thought this was possible. Now it may only change >> the Build number and not anything else, however, this is a good feature. >> Is this still possible, if so .... how do you do it? > > Haven't tried it. I only update my build number when making it available > to 3rd parties, and I do that manually. It's good enough for my purposes. > > Dave > > -- > David Webber > Mozart Music Software > http://www.mozart.co.uk > For discussion and support see > http://www.mozart.co.uk/mozartists/mailinglist.htm
From: JCO on 15 Jun 2010 19:14 This is another issue that fits in this thread. I've been messing with the GetFileVersionInfo() but when it's in my cpp, I get link errors. I can't seem to find a header file that might be missing so I don't understand it. The code snip is shown below. I have some extra code because I'm experimenting a bit but the issue is the GetFileVersionInfo() linker Issue. ********************************************************* //get filename, add .exe, then get handle to this filename CString strFileName( _T("") ); strFileName = AfxGetApp()->m_pszExeName; strFileName.Append( _T(".exe") ); HMODULE hmod = GetModuleHandle( strFileName ); //use GetModuleFileName() to obtain full path of file CString strFullPath( _T("") ); LPTSTR pstr = strFullPath.GetBufferSetLength(MAX_PATH+1); DWORD pathLen = ::GetModuleFileName( hmod, pstr, MAX_PATH); strFullPath.ReleaseBuffer( pathLen ); //Note: ReleaseBuffer doesn't need a +1 for the null byte //Use GetFileVersionInfo() to get file information TCHAR szExePath[MAX_PATH]; ::GetModuleFileName( NULL, szExePath, MAX_PATH ); DWORD dwDummy; DWORD dwFVISize = GetFileVersionInfoSize( szExePath, &dwDummy ); LPBYTE lpVersionInfo = new BYTE[dwFVISize]; GetFileVersionInfo( szExePath , 0 , dwFVISize , lpVersionInfo ); if( lpVersionInfo ) delete lpVersionInfo; VS_FIXEDFILEINFO *lpFfi; DWORD dwFileVersionMS = lpFfi->dwFileVersionMS; DWORD dwFileVersionLS = lpFfi->dwFileVersionLS; DWORD dwLeftMost = HIWORD(dwFileVersionMS); DWORD dwSecondLeft = LOWORD(dwFileVersionMS); DWORD dwSecondRight = HIWORD(dwFileVersionLS); DWORD dwRightMost = LOWORD(dwFileVersionLS); CString sMsg; sMsg.Format( _T("Version: %d.%d.%d.%d") , dwLeftMost, dwSecondLeft,dwSecondRight, dwRightMost ); MessageBox( sMsg ); ******************************************************** These are the liker Errors: Error 1 error LNK2019: unresolved external symbol _GetFileVersionInfoW(a)16 referenced in function "public: void __thiscall CAppVersionDynamicDlg::OnBnClickedButtonVersion(void)" (?OnBnClickedButtonVersion(a)CAppVersionDynamicDlg@@QAEXXZ)AppVersionDynamicDlg.obj AppVersionDynamicError 2 error LNK2019: unresolved external symbol _GetFileVersionInfoSizeW@8 referenced in function "public: void __thiscall CAppVersionDynamicDlg::OnBnClickedButtonVersion(void)" (?OnBnClickedButtonVersion(a)CAppVersionDynamicDlg@@QAEXXZ)AppVersionDynamicDlg.obj AppVersionDynamic"Joseph M. Newcomer" <newcomer(a)flounder.com> wrote in message news:cc1f16hsn3lejfmtp2b5n0a20093vii1bf(a)4ax.com... > The idea is that the header file is used to create both the string in the > About box and > the values in the .rc file that describes the VERSIONINFO. > joe > > On Mon, 14 Jun 2010 18:54:46 -0500, "JCO" <someone(a)somewhere.com> wrote: > >>I think I'm missing something but I'm interested in this topic. >>If you have your version defined in a header file, then you can display it >>in the dialog, however, if you did a "property" on the exe file, has it >>really changed? If so, then I got lost somewhere in this thread. >> >>Also; >>I was under the impression that you can set something in VS that allowed >>the >>version to change each time you do a build. I don't remember how to do >>this >>but I always thought this was possible. Now it may only change the Build >>number and not anything else, however, this is a good feature. Is this >>still possible, if so .... how do you do it? >> >>Thanks >> >> >>"Giovanni Dicanio" <giovanniDOTdicanio(a)REMOVEMEgmail.com> wrote in message >>news:eg3hiCyCLHA.2012(a)TK2MSFTNGP02.phx.gbl... >>> On 13/06/2010 15:47, RB wrote: >>> >>>> void CFileHandlingApp::OnAppAbout() >>>> { >>>> CAboutDlg aboutDlg; >>>> CString s; >>>> s.Format( _T(" version %d.%d.%d.%d"), VERMAJ, VERMIN, VERFIX, >>>> BUILDNUMBER ); >>>> aboutDlg.m_CtrlStaticVer.SetWindowText(s); //gets a Debug Assertion >>>> Failed >>>> aboutDlg.DoModal(); >>> >>> You may want to add a method to your CAboutDlg class like >>> SetVersionString(LPCTSTR pszVersion) and a data member of type CString >>> (e.g. CString m_strVersion). >>> This new method should set the version string, storing it into the >>> proper >>> data member. >>> >>> Then, CAboutDlg::OnInitDialog would get this string and .SetWindowText() >>> it in the proper static control. >>> >>> e.g.: >>> >>> class CAboutDlg >>> { >>> ... >>> public: >>> void SetVersionString(LPCTSTR pszVersion) >>> { >>> m_strVersion = pszVersion; >>> } >>> >>> ... >>> >>> private: >>> CString m_strVersion; >>> }; >>> >>> In CAboudDlg::OnInitDialog() do: >>> >>> m_CtrlStaticVer.SetWindowText(m_strVersion); >>> >>> >>> Giovanni > Joseph M. Newcomer [MVP] > email: newcomer(a)flounder.com > Web: http://www.flounder.com > MVP Tips: http://www.flounder.com/mvp_tips.htm
From: RB on 15 Jun 2010 19:21
> "JCO" wrote > Yes I got it to work. I had some code in the cpp file that was causing the > link error. I will review what I have done now.. but everything seems > okay and works. Good I think you will find it convenient. If you work it right you only have to edit the header file when anything changes and then the rest updates itself on compile. Remember to always keep spaces between items and the quotation marks or you will end up seeing quotations in the output. See comment below, =========================================== //--in your version header file #define _STR(x) #x #define STR(x) _STR(x) #define VERMAJ 1 #define VERMIN 0 #define VERFIX 0 #define BUILDNUM 0 #define YR 2010 #define V_MA_STR_LIT STR( VERMAJ ) #define V_MI_STR_LIT STR( VERMIN ) #define V_FX_STR_LIT STR( VERFIX ) #define B_N_STR_LIT STR( BUILDNUM ) #define YR_STR_LIT STR( YR ) // must leave space between items and the quotation marks or you will end up seeing quotations in the output. #define VERSTR V_MA_STR_LIT "." V_MI_STR_LIT "." V_FX_STR_LIT "." B_N_STR_LIT "\0" #define CPY_RT_YR_STR_LITERAL "Copyright (C) " YR_STR_LIT =============================================== //----and reflected in your rc2 file------// #include "YourVersion.h" VS_VERSION_INFO VERSIONINFO FILEVERSION VERMAJ, VERMIN, VERFIX, BUILDNUM PRODUCTVERSION VERMAJ, VERMIN, VERFIX, BUILDNUM ............ .................. VALUE "FileVersion", VERSTR ................ =============================================== //----and in your About Dialog------// #include "YourVersion.h" class CAboutDlg : public CDialog { ........ private: void SetVerStr( ); CString m_strVersion, m_strCpyRightYr ; ........ } void CAboutDlg::SetVerStr( ) { m_strVersion.Format( _T(" Version %d.%d.%d.%d"), VERMAJ, VERMIN, VERFIX, BUILDNUM ); m_strCpyRightYr = _T(CPY_RT_YR_STR_LITERAL); } BOOL CAboutDlg::OnInitDialog( ) { CDialog::OnInitDialog( ); SetVerStr(); m_CtrlStaticVer.SetWindowText( m_strVersion ); m_CtrlStaticCr.SetWindowText( m_strCpyRightYr ); return TRUE; } ===================================== //-----and in your DocClass constructor--// #include "YourVersion.h" CFileHandlingDoc::CFileHandlingDoc( ) { // These are CStrings in a Version Struct VerData.Ver.Format( _T("Version %d.%d.%d.%d"), VERMAJ, VERMIN, VERFIX, BUILDNUM ); VerData.CpyRt = _T(CPY_RT_YR_STR_LITERAL); } //----and in your DocClass serialize function----// void CFileHandlingDoc::Serialize(CArchive& ar) { if (ar.IsStoring( )) { ............ ar << VerData.Ver << VerData.CpyRt; ............ } else { ............ ar >> VerData.Ver >> VerData.CpyRt; ............ } } |