// Create the command to show on the Integration settings page LPCWSTR CreateCommand(CEStr& rsReady) { rsReady = L""; for (INT_PTR i = 0; i < ourSwitches.size(); i++) { Switch* ps = ourSwitches[i]; _ASSERTE(ps && !ps->szSwitch.IsEmpty()); bool bOpt = !ps->szOpt.IsEmpty(); bool bQuot = (bOpt && IsQuotationNeeded(ps->szOpt)); lstrmerge(&rsReady.ms_Val, ps->szSwitch, bOpt ? L" " : NULL, bQuot ? L"\"" : NULL, bOpt ? ps->szOpt.c_str() : NULL, bQuot ? L"\" " : L" "); } if (!rsReady.IsEmpty() || bCmdList) { lstrmerge(&rsReady.ms_Val, bCmdList ? L"-runlist " : L"-run ", szCmd); } else { rsReady.Set(szCmd); } return rsReady.c_str(L""); };
// The function converts UTF-8 to UCS2 (CEStr) and returns pointer to allocated buffer (CEStr) LPCWSTR SettingsXML::utf2wcs(const char* utf8, CEStr& wc) { if (!utf8) { _ASSERTE(utf8 != NULL); wc.Clear(); return NULL; } wc.Empty(); int wcLen = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, NULL, 0); if (wcLen > 0) { wcLen = MultiByteToWideChar(CP_UTF8, 0, utf8, -1, wc.GetBuffer(wcLen), wcLen); if (wcLen <= 0) wc.Empty(); } return wc.c_str(); }
LPCWSTR GetDirectory(CEStr& szDir) { DWORD nLen, nMax; nMax = GetCurrentDirectory(MAX_PATH, szDir.GetBuffer(MAX_PATH)); if (!nMax) { szDir.Empty(); goto wrap; } else if (nMax > MAX_PATH) { nLen = GetCurrentDirectory(nMax, szDir.GetBuffer(nMax)); if (!nLen || (nLen > nMax)) { szDir.Empty(); goto wrap; } } wrap: return szDir.IsEmpty() ? NULL : szDir.c_str(); }