Index: scripts/setup.iss =================================================================== diff -u -N -r27474113d5f01439c44834bf6088c2e112187997 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- scripts/setup.iss (.../setup.iss) (revision 27474113d5f01439c44834bf6088c2e112187997) +++ scripts/setup.iss (.../setup.iss) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -1,8 +1,9 @@ ; Script generated by the Inno Setup Script Wizard. ; SEE THE DOCUMENTATION FOR DETAILS ON CREATING INNO SETUP SCRIPT FILES! - -#define MyAppName "Copy Handler" -#define MyAppVerName "Copy Handler 1.30beta-svn70" +#define SETUP_COMPILER 1 +#include "../src/common/version.h" +#define MyAppName PRODUCT_NAME +#define MyAppVerName PRODUCT_NAME + " " + PRODUCT_VERSION #define MyAppPublisher "J�zef Starosczyk" #define MyAppURL "http://www.copyhandler.com" #define MyAppExeName "ch.exe" @@ -16,12 +17,13 @@ AppUpdatesURL={#MyAppURL} DefaultDirName={pf}\{#MyAppName} DefaultGroupName={#MyAppName} -AllowNoIcons=yes +AllowNoIcons=true LicenseFile=..\License.txt OutputDir=..\bin OutputBaseFilename=ch Compression=lzma -SolidCompression=yes +SolidCompression=true +AppMutex=_Copy handler_ instance [Languages] Name: english; MessagesFile: compiler:Default.isl @@ -53,7 +55,7 @@ Source: ..\bin\release\ch.exe; DestDir: {app}; Flags: ignoreversion Source: ..\License.txt; DestDir: {app}; Flags: ignoreversion Source: ..\bin\release\chext.dll; DestDir: {app}; Flags: ignoreversion restartreplace uninsrestartdelete -Source: ..\bin\release\libicpf*.dll; DestDir: {app}; Flags: ignoreversion +Source: ..\bin\release\libicpf32u.dll; DestDir: {app}; Flags: ignoreversion Source: ..\bin\release\ch.ini.template; DestDir: {app}; Flags: ignoreversion Source: ..\bin\release\help\*; DestDir: {app}\help; Flags: ignoreversion recursesubdirs createallsubdirs Source: ..\bin\release\langs\*; DestDir: {app}\langs; Flags: ignoreversion recursesubdirs createallsubdirs Index: src/ch/AppHelper.cpp =================================================================== diff -u -N -r4c272b19c74694c428c943011f279ec064fbd894 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision 4c272b19c74694c428c943011f279ec064fbd894) +++ src/ch/AppHelper.cpp (.../AppHelper.cpp) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -1,11 +1,14 @@ #include "stdafx.h" #include "AppHelper.h" #include "shlobj.h" +#include "../common/version.h" #ifdef _DEBUG #define new DEBUG_NEW #endif +#define CH_MUTEX_NAME _T("_Copy handler_ instance") + CAppHelper::CAppHelper() { // read program paths @@ -17,12 +20,6 @@ // single-instance protection m_bFirstInstance=true; m_hMutex=NULL; - - // name of the protection mutex - size_t stSize = _tcslen(m_pszAppName)+sizeof(_T("__ instance"))/sizeof(TCHAR)+1; - m_pszMutexName=new TCHAR[stSize]; - _sntprintf(m_pszMutexName, stSize, _T("_%s_ instance"), m_pszAppName); - _tcslwr(m_pszMutexName+2); // first letter of appname has to be of predefined case } CAppHelper::~CAppHelper() @@ -32,16 +29,12 @@ delete [] m_pszProgramPath; delete [] m_pszProgramName; - delete [] m_pszAppName; - delete [] m_pszAppNameVer; - delete [] m_pszAppVersion; - delete [] m_pszMutexName; } // inits mutex app protection void CAppHelper::InitProtection() { - m_hMutex=CreateMutex(NULL, TRUE, m_pszMutexName); + m_hMutex=CreateMutex(NULL, TRUE, CH_MUTEX_NAME); m_bFirstInstance=(m_hMutex != NULL && GetLastError() != ERROR_ALREADY_EXISTS); } @@ -85,77 +78,9 @@ void CAppHelper::RetrieveAppInfo() { - if (m_pszAppName) - { - delete [] m_pszAppName; - m_pszAppName=NULL; - } - if (m_pszAppNameVer) - { - delete [] m_pszAppNameVer; - m_pszAppNameVer=NULL; - } - if (m_pszAppVersion) - { - delete [] m_pszAppVersion; - m_pszAppVersion=NULL; - } - - TCHAR *pszPath=new TCHAR[_tcslen(m_pszProgramPath)+_tcslen(m_pszProgramName)+2]; - _tcscpy(pszPath, m_pszProgramPath); - _tcscat(pszPath, _T("\\")); - _tcscat(pszPath, m_pszProgramName); - - DWORD dwHandle; - DWORD dwSize=GetFileVersionInfoSize(pszPath, &dwHandle); - if (dwSize) - { - BYTE *pbyBuffer=new BYTE[dwSize]; - if (GetFileVersionInfo(pszPath, 0, dwSize, pbyBuffer)) - { - TCHAR* pszProp; - UINT uiLen; - // product name with short version number - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductName"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppNameVer=new TCHAR[uiLen]; - _tcscpy(m_pszAppNameVer, pszProp); - } - - // product long version - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\ProductVersion"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppVersion=new TCHAR[uiLen]; - _tcscpy(m_pszAppVersion, pszProp); - } - - // product name without version number - if (VerQueryValue(pbyBuffer, _T("\\StringFileInfo\\040904b0\\InternalName"), (LPVOID*)&pszProp, &uiLen)) - { - m_pszAppName=new TCHAR[uiLen]; - _tcscpy(m_pszAppName, pszProp); - } - } - - delete [] pbyBuffer; - } - delete [] pszPath; - - if (m_pszAppNameVer == NULL) - { - m_pszAppNameVer=new TCHAR[sizeof(_T("Unknown App 1.0"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppNameVer, _T("Unknown App 1.0")); - } - if (m_pszAppVersion == NULL) - { - m_pszAppVersion=new TCHAR[sizeof(_T("1.0.0.0"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppVersion, _T("1.0.0.0")); - } - if (m_pszAppName == NULL) - { - m_pszAppName=new TCHAR[sizeof(_T("Unknown App"))/sizeof(TCHAR)]; - _tcscpy(m_pszAppName, _T("Unknown App")); - } + m_pszAppName = _T(PRODUCT_NAME); + m_pszAppNameVer = PRODUCT_FULL_VERSION_T; + m_pszAppVersion = _T(PRODUCT_VERSION); } // internal func - safe getting special folder locations @@ -238,7 +163,7 @@ else if (_tcsnicmp(pszString, _T(""), 9) == 0) // app data { // get windows path - UINT uiSize=GetFolderLocation(CSIDL_APPDATA, szStr); + UINT uiSize=GetFolderLocation(CSIDL_LOCAL_APPDATA, szStr); if (szStr[uiSize-1] == _T('\\')) szStr[uiSize-1]=_T('\0'); _tcscat(szStr, pszString+9); @@ -267,6 +192,24 @@ return pszString; } +bool CAppHelper::GetProgramDataPath(CString& rStrPath) +{ + HRESULT hResult = SHGetFolderPath(NULL, CSIDL_LOCAL_APPDATA, NULL, 0, rStrPath.GetBufferSetLength(_MAX_PATH)); + rStrPath.ReleaseBuffer(); + if(FAILED(hResult)) + return false; + + if(rStrPath.Right(1) != _T('\\')) + rStrPath += _T('\\'); + + // make sure to create the required directories if they does not exist + rStrPath += _T("\\Copy Handler"); + if(!CreateDirectory(rStrPath, NULL) && GetLastError() != ERROR_ALREADY_EXISTS) + return false; + + return true; +} + void CAppHelper::SetAutorun(bool bState) { // storing key in registry Index: src/ch/AppHelper.h =================================================================== diff -u -N -r3493e9fc470285b0a0b417d50be281467a071eb7 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/AppHelper.h (.../AppHelper.h) (revision 3493e9fc470285b0a0b417d50be281467a071eb7) +++ src/ch/AppHelper.h (.../AppHelper.h) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -19,6 +19,8 @@ PCTSTR GetProgramPath() const { return m_pszProgramPath; }; PCTSTR GetProgramName() const { return m_pszProgramName; }; + static bool GetProgramDataPath(CString& rStrPath); + protected: void InitProtection(); // optional call - protects from running multiple instance void RetrievePaths(); // reads program's path and name @@ -28,7 +30,6 @@ protected: HANDLE m_hMutex; bool m_bFirstInstance; // tells if it is first instance(true) or second(or third, ...) - TCHAR *m_pszMutexName; // name of the protection mutex // program placement TCHAR* m_pszProgramPath; // path from which this program was run Index: src/ch/CfgProperties.cpp =================================================================== diff -u -N -rcdf6a22ddf857f56ce2e27e26d8cd6f0b8034b2e -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision cdf6a22ddf857f56ce2e27e26d8cd6f0b8034b2e) +++ src/ch/CfgProperties.cpp (.../CfgProperties.cpp) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -39,7 +39,7 @@ pManager->register_bool(_t("Program/Force shutdown"), false); pManager->register_signed_num(_t("Program/Autosave interval"), 30*llSecond, 0, 24*llHour); pManager->register_signed_num(_t("Program/Process priority class"), NORMAL_PRIORITY_CLASS, 0, 0xffffffff); - pManager->register_string(_t("Program/Autosave directory"), _t("\\"), icpf::property::flag_path); + pManager->register_string(_t("Program/Autosave directory"), _t("\\"), icpf::property::flag_path); pManager->register_string(_t("Program/Plugins directory"), _t("\\Plugins\\"), icpf::property::flag_path); pManager->register_string(_t("Program/Help directory"), _t("\\Help\\"), icpf::property::flag_path); pManager->register_string(_t("Program/Language"), _t("\\Langs\\English.lng")); @@ -100,7 +100,7 @@ pManager->register_bool(_t("Buffer/Use no buffering for large files"), true); pManager->register_signed_num(_t("Buffer/Large files lower boundary limit"), 2097152, 1, 0xffffffff); - pManager->register_string(_t("Log file/Path to main log file"), _t("\\ch.log")); + pManager->register_string(_t("Log file/Path to main log file"), _t("\\ch.log")); pManager->register_bool(_t("Log file/Enable logging"), true); pManager->register_bool(_t("Log file/Enable log size limitation"), true); pManager->register_signed_num(_t("Log file/Max log size limit"), 65535, 1024, 0xffffffff); Index: src/ch/CrashDlg.cpp =================================================================== diff -u -N -r27c0d76ec85a30292d8c474a1f4f969a9a32c406 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/CrashDlg.cpp (.../CrashDlg.cpp) (revision 27c0d76ec85a30292d8c474a1f4f969a9a32c406) +++ src/ch/CrashDlg.cpp (.../CrashDlg.cpp) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -4,7 +4,7 @@ #include "stdafx.h" #include "ch.h" #include "CrashDlg.h" -#include "version.h" +#include "../common/version.h" #define IDS_CRASH_TITLE _T("Application crashed") #define IDS_STATIC_INFO _T("Copy Handler encountered an internal problem and will be closed.\n\nIf you want to help correct this problem in the future releases of program you can send the crash information to the author of this program (e-mail it to ixen@copyhandler.com).") @@ -53,7 +53,7 @@ SetWindowText(IDS_CRASH_TITLE); m_ctlInfo.SetWindowText(IDS_STATIC_INFO); m_ctlVersionInfo.SetWindowText(IDS_VERSIONINFO_STATIC); - m_ctlVersion.SetWindowText(PRODUCT_FULL_VERSION); + m_ctlVersion.SetWindowText(PRODUCT_FULL_VERSION_T); m_ctlLocationInfo.SetWindowText(IDS_LOCATIONINFO_STATIC); if(m_bResult) m_ctlLocation.SetWindowText(m_strFilename); Index: src/ch/MainWnd.cpp =================================================================== diff -u -N -rd9426ed7d789d5a039b3d5bb92ef086c687ba285 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision d9426ed7d789d5a039b3d5bb92ef086c687ba285) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -110,7 +110,8 @@ { // create system tray icon HICON hIcon=(HICON)GetResManager()->LoadImage(MAKEINTRESOURCE(IDR_MAINFRAME), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR | LR_VGACOLOR); - bool bRes=m_ctlTray.CreateIcon(m_hWnd, WM_TRAYNOTIFY, GetApp()->GetAppNameVer(), hIcon, 0); + PCTSTR pszAppVer = GetApp()->GetAppNameVer(); + bool bRes=m_ctlTray.CreateIcon(m_hWnd, WM_TRAYNOTIFY, pszAppVer, hIcon, 0); if (!bRes) { // GetLog()->Log(_T("[CMainWnd] ... creating tray icon failed.")); Index: src/ch/ch.cpp =================================================================== diff -u -N -r7a096cad617f85582370a1c788c45442d39efc8c -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/ch.cpp (.../ch.cpp) (revision 7a096cad617f85582370a1c788c45442d39efc8c) +++ src/ch/ch.cpp (.../ch.cpp) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -26,7 +26,7 @@ #include "..\common\ipcstructs.h" #include #include "CrashDlg.h" -#include "version.h" +#include "../common/version.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -251,16 +251,20 @@ // load configuration m_cfgSettings.set_callback(ConfigPropertyChangedCallback, NULL); - TCHAR szPath[_MAX_PATH]; - _tcscpy(szPath, GetProgramPath()); - _tcscat(szPath, _T("\\ch.ini")); - try + CString strPath; + // note that the GetProgramDataPath() below should create a directory; ExpandPath() could + // depend on the directory to be created earlier + if(GetProgramDataPath(strPath)) { - m_cfgSettings.read(szPath); + strPath += _T("\\ch.ini"); + try + { + m_cfgSettings.read(strPath); + } + catch(...) + { + } } - catch(...) - { - } // register all properties RegisterProperties(&m_cfgSettings); @@ -270,6 +274,7 @@ ::SetPriorityClass(hProcess, (DWORD)m_cfgSettings.get_signed_num(PP_PPROCESSPRIORITYCLASS)); // set current language + TCHAR szPath[_MAX_PATH]; m_resManager.Init(AfxGetInstanceHandle()); m_resManager.SetCallback((PFNNOTIFYCALLBACK)MainRouter); m_cfgSettings.get_string(PP_PLANGUAGE, szPath, _MAX_PATH); @@ -282,9 +287,6 @@ return FALSE; } - // load crash string just in case - m_strCrashInfo = m_resManager.LoadString(IDS_CRASH_STRING); - // for dialogs CLanguageDialog::SetResManager(&m_resManager); Index: src/ch/ch.h =================================================================== diff -u -N -rebabad67cdda34ed4e36ab794e10d0ade8124bf3 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/ch.h (.../ch.h) (revision ebabad67cdda34ed4e36ab794e10d0ade8124bf3) +++ src/ch/ch.h (.../ch.h) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -85,7 +85,7 @@ // Implementation HANDLE m_hMapObject; TCHAR m_szHelpPath[_MAX_PATH]; // full file path to the help file - CString m_strCrashInfo; // crash info text +// CString m_strCrashInfo; // crash info text //{{AFX_MSG(CCopyHandlerApp) //}}AFX_MSG Index: src/ch/ch.vc90.vcproj =================================================================== diff -u -N -r27474113d5f01439c44834bf6088c2e112187997 -r7c612814a43eb389fa1ac27ccd8f621fd4ff37e8 --- src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 27474113d5f01439c44834bf6088c2e112187997) +++ src/ch/ch.vc90.vcproj (.../ch.vc90.vcproj) (revision 7c612814a43eb389fa1ac27ccd8f621fd4ff37e8) @@ -243,6 +243,7 @@ BrowseInformation="0" WarningLevel="4" SuppressStartupBanner="true" + DebugInformationFormat="3" />