Index: src/ch/ch.cpp =================================================================== diff -u -r7972b0944e0a947144fbdb93262f7d73ac528dc7 -r694e362bf3ce049a7bbba8b4cf442d07e6741901 --- src/ch/ch.cpp (.../ch.cpp) (revision 7972b0944e0a947144fbdb93262f7d73ac528dc7) +++ src/ch/ch.cpp (.../ch.cpp) (revision 694e362bf3ce049a7bbba8b4cf442d07e6741901) @@ -85,7 +85,7 @@ // CCopyHandlerApp construction // main routing function - routes any message that comes from modules -void ResManCallback(uint_t uiMsg) +void ResManCallback(unsigned int uiMsg) { theApp.OnResManNotify(uiMsg); } @@ -138,14 +138,12 @@ bool bChanged=false; // flag that'll be returned - if the paths has changed // generate the current filename - uses language from config - TCHAR szBuffer[_MAX_PATH]; - _tcscpy(szBuffer, _T("\\Help\\")); - ExpandPath(szBuffer); - _tcscat(szBuffer, GetResManager().m_ld.GetHelpName()); - if(_tcscmp(szBuffer, m_pszHelpFilePath) != 0) + CString strHelpPath = ExpandPath(_T("\\Help\\")); + strHelpPath += GetResManager().m_ld.GetHelpName(); + if(strHelpPath != m_pszHelpFilePath) { free((void*)m_pszHelpFilePath); - m_pszHelpFilePath = _tcsdup(szBuffer); + m_pszHelpFilePath = _tcsdup(strHelpPath); bChanged=true; } @@ -175,14 +173,14 @@ GetLocalTime(&st); TCHAR szName[_MAX_PATH]; - _sntprintf(szName, _MAX_PATH, _T("%s\\ch_crashdump-%s-%I64u-%s.dmp"), (PCTSTR)strPath, _T(PRODUCT_VERSION), (ull_t)_time64(NULL), + _sntprintf(szName, _MAX_PATH, _T("%s\\ch_crashdump-%s-%I64u-%s.dmp"), (PCTSTR)strPath, _T(PRODUCT_VERSION), (unsigned long long)_time64(NULL), #ifdef _WIN64 _T("64") #else _T("32") #endif ); - szPath[_MAX_PATH - 1] = _T('\0'); + szName[_MAX_PATH - 1] = _T('\0'); // Step 2 - create the crash dump in case anything happens later bool bResult = false; @@ -349,7 +347,7 @@ rResManager.SetCallback(ResManCallback); GetPropValue(rCfg, strPath); TRACE(_T("Help path=%s\n"), strPath); - if(!rResManager.SetLanguage(ExpandPath(strPath.GetBufferSetLength(_MAX_PATH)))) + if(!rResManager.SetLanguage(ExpandPath(strPath))) { TCHAR szData[2048]; _sntprintf(szData, 2048, _T("Couldn't find the language file specified in configuration file:\n%s\nPlease correct this path to point the language file to use.\nProgram will now exit."), (PCTSTR)strPath); @@ -365,6 +363,17 @@ EnableHtmlHelp(); + // ================================= Handle early command line options ======================================== + if(m_cmdLineParser.HasCommandLineParams() && m_cmdLineParser.HasSystemStartupOption()) + { + SetPropValue(rCfg, m_cmdLineParser.IsSystemStartupEnabled()); + rCfg.Write(); + + SetAutorun(GetPropValue(rCfg)); + + return FALSE; + } + // ================================= Checking for running instances of CH ======================================== // check instance - return false if it's the second one LOG_INFO(_T("Checking for other running instances of Copy Handler")); @@ -531,7 +540,7 @@ else if(hResult == S_FALSE) { CString strMsg; - strMsg.Format(_T("Shell extension has different version (0x%lx) than Copy Handler (0x%lx)."), lExtensionVersion, PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4); + strMsg.Format(_T("Shell extension has different version (0x%lx) than Copy Handler (0x%lx)."), (unsigned long)lExtensionVersion, (unsigned long)(PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4)); LOG_WARNING(strMsg); switch(iDoNotShowAgain_VersionMismatch) @@ -586,15 +595,15 @@ chcore::TString strError = chcore::TWin32ErrorFormatter::FormatWin32ErrorCode(hResult, true); ictranslate::CFormat fmt(GetResManager().LoadString(IDS_REGISTERERR_STRING)); - fmt.SetParam(_T("%errno"), (ulong_t)hResult); + fmt.SetParam(_T("%errno"), (unsigned long)hResult); fmt.SetParam(_T("%errdesc"), strError.c_str()); AfxMessageBox(fmt, MB_ICONERROR | MB_OK); } else if(hResult == S_FALSE) { // registered ok, but incompatible versions - probably restart required CString strMsg; - strMsg.Format(_T("Registration succeeded, but still the shell extension has different version (0x%lx) than Copy Handler (0x%lx)."), lExtensionVersion, PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4); + strMsg.Format(_T("Registration succeeded, but still the shell extension has different version (0x%lx) than Copy Handler (0x%lx)."), (unsigned long)lExtensionVersion, (unsigned long)(PRODUCT_VERSION1 << 24 | PRODUCT_VERSION2 << 16 | PRODUCT_VERSION3 << 8 | PRODUCT_VERSION4)); LOG_WARNING(strMsg); MsgBox(IDS_SHELL_EXTENSION_REGISTERED_MISMATCH_STRING, MB_ICONWARNING | MB_OK); @@ -623,7 +632,7 @@ chcore::TString strError = chcore::TWin32ErrorFormatter::FormatWin32ErrorCode(hResult, true); ictranslate::CFormat fmt(GetResManager().LoadString(IDS_UNREGISTERERR_STRING)); - fmt.SetParam(_T("%errno"), (ulong_t)hResult); + fmt.SetParam(_T("%errno"), (unsigned long)hResult); fmt.SetParam(_T("%errdesc"), strError.c_str()); AfxMessageBox(fmt, MB_ICONERROR | MB_OK); @@ -640,8 +649,7 @@ // update language in resource manager CString strPath; GetPropValue(GetConfig(), strPath); - GetResManager().SetLanguage(ExpandPath(strPath.GetBufferSetLength(_MAX_PATH))); - strPath.ReleaseBuffer(); + GetResManager().SetLanguage(ExpandPath(strPath)); } if(setPropNames.HasValue(PropData::GetPropertyName()))