Esempio n. 1
1
bool OfflineDataStore::GetRegKeyForDocNum(const CStdString& sDocID, CRegKey& rkResult) 
{
	CStdString sNoVersionDocID = RemoveVersionLabel(sDocID);
	sNoVersionDocID.MakeLower();

	CRegKey rk;
	long lResult = rk.Open(HKEY_CURRENT_USER, GetRegistryKeyName());

	DWORD dwIndex = 0;
	while(lResult == ERROR_SUCCESS)
	{
		CStdString sResult;
		DWORD dwLength = MAX_PATH;
		lResult = rk.EnumKey(dwIndex, sResult.GetBuffer(MAX_PATH), &dwLength);
		sResult.ReleaseBuffer();
		sResult.MakeLower();

		dwIndex++;
		if(sResult.Find(sNoVersionDocID) != -1)
		{
			return (rkResult.Open(HKEY_CURRENT_USER, GetKeyNameForDocID(sResult)) == ERROR_SUCCESS);
		}
	}
	return false;
}
Esempio n. 2
0
CStdString NetworkDriveHelper::MapNetworkDrive()
{
	NETRESOURCE nr;
	CStdString sDisk	= GetUnusedDiskName();
	TCHAR* pDisk		= sDisk.GetBuffer();

	CStdString sPath	= GetUNCShareName();
	TCHAR* pPath		= sPath.GetBuffer();

	nr.dwScope			= RESOURCE_CONNECTED;  
	nr.dwType			= RESOURCETYPE_DISK;  
	nr.dwDisplayType	= RESOURCEDISPLAYTYPE_GENERIC; 
	nr.dwUsage			= RESOURCEUSAGE_CONNECTABLE;  
	nr.lpLocalName		= pDisk;  
	nr.lpRemoteName		= pPath;  
	nr.lpComment		= _T("Mapped network drive for Workshare LFS Testing");  
	nr.lpProvider		= NULL;

	DWORD dwErr			= WNetAddConnection2(&nr, NULL, NULL, 0);

	sDisk.ReleaseBuffer();
	sPath.ReleaseBuffer();
	if (dwErr == NO_ERROR || dwErr == ERROR_ALREADY_ASSIGNED)
		return pDisk;

	return _T("");
}
Esempio n. 3
0
CStdString CTestUtils::GetTrunkPath()
{
	CStdString sModuleName;
	CStdString sLongModuleName;

	HMODULE hMod = GetModuleHandle(L"testrunner.dll");
	GetModuleFileName(hMod, sModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sModuleName.ReleaseBuffer();

	DWORD dRet = GetLongPathName(sModuleName, sLongModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sLongModuleName.ReleaseBuffer();
	if (dRet == 0)
	{
		sLongModuleName = sModuleName;
	}

	sModuleName = sLongModuleName;
	sModuleName.ToLower();

	if ((sModuleName.Find(ARCHDIR +  _T( "\\debug\\")) != -1) ||
		(sModuleName.Find(ARCHDIR + _T( "\\release\\")) != -1))
	{
		return PathBefore(sModuleName, ARCHDIR );
	}

	// This won't work for paths beyond the root without win32\\release but at least it doesn't crash
	// applications like deltaview when it is doing a regserver
	return PathBefore(sModuleName, "\\");
}
Esempio n. 4
0
void PathReadWriter::GetPathList(const CStdString& sPathList, std::vector<CStdString>& pathList)
{
	pathList.clear();
	pathList.reserve(std::count(sPathList.begin(), sPathList.end(), _T(';')) + 1);

	int nStartPos = 0;
	for (int nEndPos = (int) sPathList.find(_T(';'));
		nEndPos >= 0;
		nEndPos = (int) sPathList.find(_T(';'), nStartPos = nEndPos + 1))
	{
		CStdString sSubPath = sPathList.Mid(nStartPos, nEndPos - nStartPos).Trim();
		if (!sSubPath.IsEmpty())
		{
			::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
			sSubPath.ReleaseBuffer();
			pathList.push_back(sSubPath);
		}
	}
	CStdString sSubPath = sPathList.Mid(nStartPos).Trim();
	if (!sSubPath.IsEmpty())
	{
		::PathRemoveBackslash(sSubPath.GetBuffer(MAX_PATH));
		sSubPath.ReleaseBuffer();
		pathList.push_back(sSubPath);
	}
}
Esempio n. 5
0
CStdString CMarkupSTL::x_TextToDoc( const char * szText, bool bAttrib ) const
{
	// Convert text as seen outside XML document to XML friendly
	// replacing special characters with ampersand escape codes
	// E.g. convert "6>7" to "6&gt;7"
	//
	// &lt;   less than
	// &amp;  ampersand
	// &gt;   greater than
	//
	// and for attributes:
	//
	// &apos; apostrophe or single quote
	// &quot; double quote
	//
	static _TCHAR* szaReplace[] = { _T("&lt;"),_T("&amp;"),_T("&gt;"),_T("&apos;"),_T("&quot;") };
	const _TCHAR* pFind = bAttrib?_T("<&>\'\""):_T("<&>");
	CStdString csText;
	const _TCHAR* pSource = szText;
	int nDestSize = _tcslen(pSource);
	nDestSize += nDestSize / 10 + 7;
	_TCHAR* pDest = csText.GetBuffer(nDestSize);
	int nLen = 0;
	_TCHAR cSource = *pSource;
	_TCHAR* pFound;
	while ( cSource )
	{
		if ( nLen > nDestSize - 6 )
		{
			csText.ReleaseBuffer(nLen);
			nDestSize *= 2;
			pDest = csText.GetBuffer(nDestSize);
		}
		if ( (pFound=_tcschr(pFind,cSource)) != NULL )
		{
			pFound = szaReplace[pFound-pFind];
			_tcscpy(&pDest[nLen],pFound);
			nLen += _tcslen(pFound);
		}
		else
		{
			_tccpy( &pDest[nLen], pSource );
			++nLen;
		}
		pSource += _tclen( pSource );
		cSource = *pSource;
	}
	csText.ReleaseBuffer(nLen);
	return csText;
}
Esempio n. 6
0
bool DotNetRegistrar::UnregisterItem()
{
	CStdString sFileName;
	CStdString sParams;
	CreateUnregisterCommandString(sFileName, sParams);

    CFilePath exePath( GetDotNetRegistrationFileName() ); //this was retrieved in CreateRegisterCommandString, but we want one without enclosing quotes
    CStdStringA sCommand ;
    sCommand.Format("\"%s\" %s", CStdStringA(exePath.GetFileName()), CStdStringA( sParams ) );

    CStdString sBatchFile = GetExecutionPath() + _T("\\Register.bat");
    _tremove( sBatchFile.c_str());
    CreateTextFile( sBatchFile, sCommand );
    ASSERT( CGeneral::FileExists( sBatchFile ));
	
    bool res = true;
    try
    {
	    CStdString cmdLine = sBatchFile;
	    STARTUPINFO si;
	    PROCESS_INFORMATION pi;
	    ZeroMemory(&si, sizeof(si));
	    si.cb = sizeof(si);
	    si.wShowWindow = SW_HIDE;
	    ZeroMemory(&pi, sizeof(pi));
	    if ( !CreateProcess( NULL, cmdLine.GetBuffer(MAX_PATH), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi) )
	    {
		    cmdLine.ReleaseBuffer();
		    res = false;

	    }
	    cmdLine.ReleaseBuffer();	
	    if ( res )
	    {
		    // Wait around for 15 seconds 
		    WaitForSingleObject(pi.hProcess, 15000);
		    CloseHandle(pi.hProcess);
		    CloseHandle(pi.hThread);
	    }
    }
    catch(...)
    {
        _tremove( sBatchFile.c_str());
        throw;
    }

    _tremove( sBatchFile.c_str());
	return res;
}
Esempio n. 7
0
CStdString OfflineDataStore::GetStringValue(CRegKey& rk, const CStdString sValue)
{
	CStdString	sResult;
	DWORD dwSize = MAX_PATH;

	if (rk.QueryStringValue(sValue.c_str(), sResult.GetBuffer(MAX_PATH), &dwSize) != ERROR_SUCCESS)
	{
		LOG_WS_ERROR(_T("Failed to read string value"));
		sResult.ReleaseBuffer();
		return _T("");
	}

	sResult.ReleaseBuffer();
	return sResult;
}
bool SharePointConnectRegistrar::RegisterItem()
{
	STARTUPINFO si;
	ZeroMemory( &si, sizeof(STARTUPINFO) );
	si.cb = sizeof( STARTUPINFO );

	PROCESS_INFORMATION pi;
	ZeroMemory( &pi, sizeof(PROCESS_INFORMATION) );

	CStdString sInstallDir = m_pProcessController->GetInstallDir();
	CStdString sAppName = L"WCRegisterConnectSettings.exe";
	CStdString sRegXml = L"Workshare.Connect.SharePoint.Registration.xml";
	CStdString sCmdLine = sInstallDir + L"\\"+ sAppName + L" \"" + sInstallDir + "\\" + sRegXml + L"\"";

	BOOL b = ::CreateProcess( NULL, sCmdLine.GetBuffer(), NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi );
	sCmdLine.ReleaseBuffer();

	if( !b )
		return false;

	DWORD dwExitCode;
	::WaitForSingleObject( pi.hProcess, INFINITE );

	if( ::GetExitCodeProcess( pi.hProcess, &dwExitCode ) == 0 )	
	{
		::CloseHandle( pi.hProcess );
		::CloseHandle( pi.hThread );
		return false;;
	}

	::CloseHandle( pi.hProcess );
	::CloseHandle( pi.hThread );
	return true;
}
Esempio n. 9
0
CStdString CWorkshareMenu::GetSystemPath(LONG lPathClsid) const
{	
	typedef HRESULT (CALLBACK* PROC_SHGetFolderPath)(HWND, int, HANDLE, DWORD, LPTSTR);

	CStdString sPath = L"";
	bool bUsingOldDll = false;

	HMODULE hModShFolder = LoadLibrary(_T("shfolder.dll"));

	if (hModShFolder == NULL)
		return sPath;

	PROC_SHGetFolderPath proc = (PROC_SHGetFolderPath) GetProcAddress(hModShFolder, FOLDERPROCNAME);

	if (proc != NULL)
	{
		HRESULT hr = proc (NULL, lPathClsid, NULL, SHGFP_TYPE_CURRENT, sPath.GetBuffer(MAX_PATH));
		sPath.ReleaseBuffer();

		if (FAILED(hr))
		{
			CStdString sErr;
			sErr.Format(_T("Failed to get the system path (CSIDL): %d. Error: %d"), lPathClsid, hr);
			OutputDebugString(sErr.c_str());
		}
	}
	FreeLibrary(hModShFolder);

	return sPath; 
}
Esempio n. 10
0
CStdString CTestUtils::GetPath(int nFolder)
{
	CStdString sFolder;
	HRESULT hr = SHGetFolderPath(NULL, nFolder, NULL, SHGFP_TYPE_CURRENT, sFolder.GetBuffer(MAX_PATH));
	sFolder.ReleaseBuffer();
	return SUCCEEDED(hr) ? sFolder : _T("");
}
Esempio n. 11
0
bool OfflineDocIDResolver::GetOfflineDocumentInfo(const CStdString& sOnlineLibraryToSearch, const CStdString& sDocNum, CStdString& sOfflineDocNum, CStdString& sOfflineLibrary) const
{
    CRegKey key;
    if(key.Open(HKEY_CURRENT_USER, sOnlineLibraryToSearch) != ERROR_SUCCESS)
    {
        CStdString sErr = _T("Failed to Open Key : HKCU\\") + sOnlineLibraryToSearch;
        LOG_WS_ERROR(sErr.c_str());
        return false;
    }

    DWORD dwIndex = 0;
    DWORD dwLength =MAX_PATH;

    long lResult = ERROR_SUCCESS;
    while((lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA))
    {
        DWORD dwLength =MAX_PATH;
        lResult = key.EnumKey(dwIndex , sOfflineLibrary.GetBuffer(MAX_PATH), &dwLength , NULL);
        sOfflineLibrary.ReleaseBuffer();
        if(lResult == ERROR_NO_MORE_ITEMS)
            return false;

        if(SearchOfflineLibrary(sOnlineLibraryToSearch + _T("\\") + sOfflineLibrary, sDocNum, sOfflineDocNum))
            return true;

        dwIndex++;
    }

    return false;
}
Esempio n. 12
0
CStdString SystemFolderInfo::GetProfilesDirectory()
{
	CStdString profileDirectory;

	HMODULE dllHandle = ::LoadLibrary(_T("userenv.dll"));
	if(dllHandle == NULL)
	{
		LOG_WS_ERROR(_T("Failed to load userenv.dll"));
		return profileDirectory;
	}

	PROC_GetProfilesDir proc = (PROC_GetProfilesDir)::GetProcAddress(dllHandle, PROFILESPROCNAME);
	if(NULL == proc)
	{
		LOG_WS_ERROR(_T("Failed to get function 'GetProfilesDirectory'"));
		::FreeLibrary(dllHandle);
		return profileDirectory;
	}

	DWORD size = _MAX_PATH;
	BOOL bSuccess = proc(profileDirectory.GetBuffer(MAX_PATH), &size);
	profileDirectory.ReleaseBuffer();

	if(!bSuccess)
		LOG_WS_ERROR(_T("Failed to call function 'GetProfilesDirectory'"));

	::FreeLibrary(dllHandle);

	return profileDirectory;
}
Esempio n. 13
0
bool OfflineDocIDResolver::SearchOfflineLibrary(const CStdString& sLibraryToSearch, const CStdString& sDocNum, CStdString& sOfflineDocKey ) const
{
    CRegKey key;

    if( key.Open(HKEY_CURRENT_USER, sLibraryToSearch) != ERROR_SUCCESS )
    {
        CStdString sErr = _T("Failed to Open Key : HKCU\\") + sLibraryToSearch;
        LOG_WS_ERROR(sErr.c_str());
        return false;
    }

    DWORD dwIndex = 0;

    long lResult = ERROR_SUCCESS;
    while((lResult == ERROR_SUCCESS || lResult == ERROR_MORE_DATA))
    {
        DWORD dwLength =MAX_PATH;

        lResult = key.EnumKey(dwIndex , sOfflineDocKey.GetBuffer(MAX_PATH), &dwLength , NULL);
        sOfflineDocKey.ReleaseBuffer();
        if(lResult == ERROR_NO_MORE_ITEMS)
            return false;

        DWORD dw = GetDWORDValue(sLibraryToSearch + _T("\\") + sOfflineDocKey, _T("DocNumber"));
        CStdString str;
        str.Format( _T("%d"), dw );
        if( str == sDocNum )
            return true;

        dwIndex++;
    }

    return false;
}
Esempio n. 14
0
CStdString ServerSettingsDialog::GetUsername() const
{
	CStdString sRetval;
	GetDlgItem(IDC_EDIT_USERNAME).GetWindowText( sRetval.GetBuffer(MAX_PATH), MAX_PATH );
	sRetval.ReleaseBuffer();
	return sRetval;
}
Esempio n. 15
0
CStdString ServerSettingsDialog::GetPassword() const
{
	CStdString sRetval;
	GetDlgItem(IDC_EDIT_PASSWORD).GetWindowText( sRetval.GetBuffer(MAX_PATH), MAX_PATH );
	sRetval.ReleaseBuffer();
	return sRetval;
}
Esempio n. 16
0
void COptionsDlgSelector::OnOptionsSelect() 
{
	try
	{
		AnalyticsHelper::SendDeltaViewStatistics(L"DeltaView Event: Select to change rendering set");
		CStdString sOptionSetName;
		m_cboOptionsFile.GetWindowText(sOptionSetName.GetBuffer(MAX_PATH), MAX_PATH);
		sOptionSetName.ReleaseBuffer();
		bool bResult = DoShowNewRenderingSetDialog(sOptionSetName.c_str(), GetParent()->m_hWnd, false);

		if(bResult)
		{
			GetApp()->SetShouldRerunComparison(false);

			//// refresh the contents of the rendering options list as it might have changed!!
			std::vector<std::wstring> vecRenderingSets;
			RenderingSet::GetRenderingSetList(vecRenderingSets);

			m_cboOptionsFile.ResetContent();
			PopulateRenderingSetList();


			ResetOKAsDefault(true);
		}
	}
	catch(_com_error &e)
	{
		LOG_WS_ERROR_RESULT(e);
	}
	catch(...)
	{
		_ASSERTE(!_T("Catch ... How did we get here?"));
		LOG_WS_ERROR(_T("Unknown Exception"));
	}
}
Esempio n. 17
0
void COptionsDlgSelector::ValidateRenderingSetOptions()
{
	CStdString sOptionsFile;
	m_cboOptionsFile.GetWindowText(sOptionsFile.GetBuffer(MAX_PATH), MAX_PATH);
	sOptionsFile.ReleaseBuffer();
	if (m_bPageModified)
	{
		// Right-Click doesn't come in here, so start the timing from here
		LOG_WS_FUNCTION_SCOPE_MSG(_T("DeltaView Total Comparison Time"));

		if (!sOptionsFile.IsEmpty() && sOptionsFile.CompareNoCase(CStdString::LoadResource(IDS_TXTEX_customRenderingSet6129,_T("Custom rendering set"))) != 0)/* TXTEX_IGNORE */ 
		{
			if (!RenderingSet::LoadRenderingSetIfRequired(sOptionsFile))
			{
				GetApp()->ShowMessageEx(this->m_hWnd, 
					CStdStringW::LoadResource(IDS_TXTEX_theOptionsFileSpecifiedDoesNotHaveCorrectInformationPleaseMakeSureThisIsaValidOptionsFileCurrentSettingsWillBeApplied5086,_T("The options file specified does not have the correct information - please make sure this is a valid options file.\n\nCurrent settings will be applied.")),
					WsOK,
					WsDefault,
					WsErrorIcon,
					L"",
					CDeltaVwApp::GetProductHelpID(HIDC_INVALID_OPTIONS_FILE),
					LOG_LOCATION);
			}
		}
	}
}
Esempio n. 18
0
CStdString cXData::cItem_hwnd::GetValue () const {
	CStdString value;
	int size = GetWindowTextLength(hwnd);
	GetWindowText(hwnd, value.GetBuffer(size + 1), size + 1);
	value.ReleaseBuffer();
	return value;
}
Esempio n. 19
0
void TestWindowActivate::TestAttach()
{
	STARTUPINFO StartupInfo;
	PROCESS_INFORMATION ProcessInformation;
	ZeroMemory(&ProcessInformation, sizeof(PROCESS_INFORMATION));
	
	ZeroMemory(&StartupInfo, sizeof(STARTUPINFO));
	StartupInfo.cb = sizeof(STARTUPINFO);
	StartupInfo.wShowWindow = SW_SHOWNORMAL;
	StartupInfo.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
	
	assertMessage(!m_csWordPath.IsEmpty(),_T("Word path is empty - highly improbable state of affairs if you ask me"));
	CStdString sCommandLine = m_csWordPath + _T(" /W ");
	assertMessage(CreateProcess(NULL, sCommandLine.GetBuffer(), 0, 0, false, 0, 0, 0, &StartupInfo, &ProcessInformation) != 0,_T("Failed to create the Word process"));
	sCommandLine.ReleaseBuffer();

	CWSWindow win;
	win.Attach(ProcessInformation.dwProcessId);
	
	assertTest(win.GetWindowFromProcID());

	win.Activate();
	Sleep(1000);
	TerminateProcess(ProcessInformation.hProcess, 0);
}
Esempio n. 20
0
CStdStringA TerDateTimeFormatter::GetFormattedTime(SYSTEMTIME& st, const CStdStringA& sFormatPicture)
{
	CStdString sDate;
	int ir = GetTimeFormat(m_locale, 0, &st, sFormatPicture.c_str(), sDate.GetBuffer(MAX_PATH), MAX_PATH);
	sDate.ReleaseBuffer();

	return sDate;
}
Esempio n. 21
0
CStdStringA TerDateTimeFormatter::GetDefaultTimeFormat()
{
	CStdString sFormat;

	int ir = GetLocaleInfo(m_locale, LOCALE_STIMEFORMAT, sFormat.GetBuffer(MAX_PATH), MAX_PATH);
	sFormat.ReleaseBuffer();
	//GetSystemLocale
	return sFormat;
}
Esempio n. 22
0
CStdString CTestUtils::GetLongModuleName()
{
	CStdString sModuleName;
	CStdString sLongModuleName;

	HMODULE hMod = GetModuleHandle(NULL);
	GetModuleFileName(hMod, sModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sModuleName.ReleaseBuffer();

	DWORD dRet = GetLongPathName(sModuleName, sLongModuleName.GetBuffer(MAX_PATH), MAX_PATH);
	sLongModuleName.ReleaseBuffer();
	if (dRet == 0)
	{
		sLongModuleName = sModuleName;
	}

	return sLongModuleName;
}
Esempio n. 23
0
bool RegUtils::SetRegStringValue(HKEY hKeyRoot, CStdString sSubKey, CStdString sValueName, CStdString sValue)
{
	HKEY hKey;
	if (RegOpenKeyEx(hKeyRoot, sSubKey, 0, KEY_WRITE, &hKey) != ERROR_SUCCESS)
	{
		return false;
	}

	if (RegSetValueEx(hKey, sValueName, 0, REG_SZ, (BYTE*)sValue.GetBuffer(), (DWORD)sValue.length()*sizeof(TCHAR)) != ERROR_SUCCESS)
	{
		sValue.ReleaseBuffer();
		CloseKey(hKey);
		return false;
	}
	sValue.ReleaseBuffer();
	CloseKey(hKey);

	return true;
}
Esempio n. 24
0
	std::string regQueryString(HKEY hKey , const char * name, const char * def) {
		unsigned long type=0,count=0;
		if (RegQueryValueEx(hKey,(LPCTSTR)name,0,&type,0,&count) == ERROR_SUCCESS && type == REG_SZ) {
			CStdString buff;
			if (!RegQueryValueEx(hKey,(LPCTSTR)name,0,&type,(LPBYTE)buff.GetBuffer(count-1),&count)) {
				buff.ReleaseBuffer();
				return buff;
			}
		}
		return def ? def : "";
	}
Esempio n. 25
0
CStdString CMarkupSTL::x_TextFromDoc( int nLeft, int nRight ) const
{
	// Convert XML friendly text to text as seen outside XML document
	// replacing ampersand escape codes with special characters
	// E.g. convert "6&gt;7" to "6>7"
	//
	// Conveniently the result is always the same or shorter in length
	//
	static _TCHAR* szaCode[] = { _T("lt;"),_T("amp;"),_T("gt;"),_T("apos;"),_T("quot;") };
	static int anCodeLen[] = { 3,4,3,5,5 };
	static _TCHAR* szSymbol = _T("<&>\'\"");
	CStdString csText;
	const _TCHAR* pSource = m_csDoc;
	int nDestSize = nRight - nLeft + 1;
	_TCHAR* pDest = csText.GetBuffer(nDestSize);
	int nLen = 0;
	int nCharLen;
	int nChar = nLeft;
	while ( nChar <= nRight )
	{
		if ( pSource[nChar] == _T('&') )
		{
			// Look for matching &code;
			for ( int nMatch = 0; nMatch < 5; ++nMatch )
			{
				if ( nChar <= nRight - anCodeLen[nMatch]
					&& _tcsncmp(szaCode[nMatch],&pSource[nChar+1],anCodeLen[nMatch]) == 0 )
				{
					pDest[nLen++] = szSymbol[nMatch];
					nChar += anCodeLen[nMatch] + 1;
					break;
				}
			}

			// If no match is found it means XML doc is invalid
			// no devastating harm done, ampersand code will just be left in result
			if ( nMatch == 5 )
			{
				pDest[nLen++] = _T('&');
				++nChar;
			}
		}
		else
		{
			nCharLen = _tclen(&pSource[nChar]);
			_tccpy( &pDest[nLen], &pSource[nChar] );
			nLen += nCharLen;
			nChar += nCharLen;
		}
	}
	csText.ReleaseBuffer(nLen);
	return csText;
}
Esempio n. 26
0
CStdString OfflineDocIDResolver::GetStringValue(const CStdString& sKey, const CStdString& sName ) const
{
    CRegKey reg;
    CStdString sValue;
    if(reg.Open(HKEY_CURRENT_USER , sKey) != ERROR_SUCCESS)
    {
        CStdString sErr = _T("Failed to Open Key : ") + sKey;
        LOG_WS_ERROR(sErr.c_str());
        return _T("");
    }
    ULONG pSize;
    if(reg.QueryStringValue(sName , sValue.GetBuffer(MAX_PATH), &pSize) != ERROR_SUCCESS)
    {
        sValue.ReleaseBuffer();
        CStdString sErr = _T("Failed to Read String value for key : ")  + sKey;
        LOG_WS_ERROR(sErr.c_str());
        return _T("");
    }

    sValue.ReleaseBuffer();
    return sValue;
}
Esempio n. 27
0
bool PathReadWriter::DoesPathExistInRegistry(const CStdString& sSubPath) const
{
	CStdString sPath = sSubPath;
	::PathRemoveBackslash(sPath.GetBuffer(MAX_PATH));
	sPath.ReleaseBuffer();
	sPath.Trim();
	if (sPath.IsEmpty())
	{
		return false;
	}

	std::vector<CStdString> pathList;
	GetPathListFromRegistry(pathList);
	return (std::find_if(pathList.begin(), pathList.end(), MatchesPath(sPath)) != pathList.end());
}
Esempio n. 28
0
void cXData::cItem_result::OnDoubleClick(cXData * owner) {
	int pos = ListView_GetSelectionMark(hwnd);
	if (pos == -1 || this->jidColumn == -1)
		return;
	CStdString jid;
	ListView_GetItemText(hwnd, pos, this->jidColumn, jid.GetBuffer(200), 200);
	jid.ReleaseBuffer();
	if (owner->Jab().FindContact(jid) == -1) {
		int id = owner->Jab().GetPlug()->ICMessage(IMC_CNT_ADD, kJabber::net, (int)jid.c_str());
		if (id == -1)
			return;
		owner->Jab().GetPlug()->DTsetStr(DTCNT, id, CNT_GROUP, owner->Jab().GetPlug()->DTgetStr(DTCFG, 0, CFG_CURGROUP));
		owner->Jab().GetPlug()->ICMessage(IMC_CNT_CHANGED, id);
	}
}
Esempio n. 29
0
std::vector<WSDocumentVersionNoCom> OfflineDataStore::GetVersionList( const CStdString& sDocID )
{
	std::vector<WSDocumentVersionNoCom> vVersionList;
	CRegKey rk;
	if(GetRegKeyForDocNum(sDocID, rk))
	{
		CStdString sDocDescription = GetStringValue(rk, _T("Description"));
		CStdString sVersionList;
		ULONG length = MAX_PATH;
		rk.QueryStringValue( _T("VersionList"), sVersionList.GetBuffer(MAX_PATH), &length );
		sVersionList.ReleaseBuffer();
		vVersionList = ParseVersionList(sVersionList, sDocID, sDocDescription);
	}
	return vVersionList;
}
Esempio n. 30
0
CStdString CDefragStorage::GetTempPathName()
{
	CStdString sTempPath;

	::GetTempPath(_MAX_PATH, sTempPath.GetBuffer(_MAX_PATH));
	sTempPath.ReleaseBuffer();

	sTempPath += _T("workshare\\");
	if (!DirectoryExists(sTempPath))
		_tmkdir(sTempPath.c_str());		

	sTempPath += TEMP_FILE_DIR + GetPID() + _T("\\");

	return sTempPath;
}