当前位置: 首页>>代码示例>>C++>>正文


C++ CStdString::ReleaseBuffer方法代码示例

本文整理汇总了C++中CStdString::ReleaseBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::ReleaseBuffer方法的具体用法?C++ CStdString::ReleaseBuffer怎么用?C++ CStdString::ReleaseBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CStdString的用法示例。


在下文中一共展示了CStdString::ReleaseBuffer方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetPathList

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);
	}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:PathReadWriter.cpp

示例2: GetTrunkPath

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, "\\");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:29,代码来源:TestUtils.cpp

示例3: MapNetworkDrive

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("");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:27,代码来源:NetworkDriveHelper.cpp

示例4: x_TextToDoc

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;
}
开发者ID:Avoidnf8,项目名称:xbmc-fork,代码行数:50,代码来源:MarkupSTL.cpp

示例5: UnregisterItem

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:49,代码来源:DotNetRegistrar.cpp

示例6: GetStringValue

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:15,代码来源:OfflineDataStore.cpp

示例7: RegisterItem

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:SharePointConnectRegistrar.cpp

示例8: GetSystemPath

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; 
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:WorkshareMenu.cpp

示例9: GetPath

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("");
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:7,代码来源:TestUtils.cpp

示例10: GetOfflineDocumentInfo

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:OfflineDocIDResolver.cpp

示例11: SearchOfflineLibrary

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:34,代码来源:OfflineDocIDResolver.cpp

示例12: GetProfilesDirectory

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:30,代码来源:SystemFolderInfo.cpp

示例13: TestAttach

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);
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:DemoTestClass.cpp

示例14: GetRegKeyForDocNum

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;
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:25,代码来源:OfflineDataStore.cpp

示例15: ValidateRenderingSetOptions

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);
			}
		}
	}
}
开发者ID:killbug2004,项目名称:WSProf,代码行数:26,代码来源:OptionsDlgSelector.cpp


注:本文中的CStdString::ReleaseBuffer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。