本文整理汇总了C++中CStdString::GetBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ CStdString::GetBuffer方法的具体用法?C++ CStdString::GetBuffer怎么用?C++ CStdString::GetBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CStdString
的用法示例。
在下文中一共展示了CStdString::GetBuffer方法的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);
}
}
示例2: 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("");
}
示例3: 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, "\\");
}
示例4: GetImage
bool CImageCode::GetImage(CStdString strURL, CStdString strLocFile)
{
BOOL bRes = InternetGetFile(strURL.GetBuffer(), strLocFile.GetBuffer());
if (bRes)
{
return true;
}
return false;
}
示例5: 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>7"
//
// < less than
// & ampersand
// > greater than
//
// and for attributes:
//
// ' apostrophe or single quote
// " double quote
//
static _TCHAR* szaReplace[] = { _T("<"),_T("&"),_T(">"),_T("'"),_T(""") };
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;
}
示例6: 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("");
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: OnOptionsSelect
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"));
}
}
示例11: GetPassword
CStdString ServerSettingsDialog::GetPassword() const
{
CStdString sRetval;
GetDlgItem(IDC_EDIT_PASSWORD).GetWindowText( sRetval.GetBuffer(MAX_PATH), MAX_PATH );
sRetval.ReleaseBuffer();
return sRetval;
}
示例12: 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;
}
示例13: GetWindowTextLength
CStdString cXData::cItem_hwnd::GetValue () const {
CStdString value;
int size = GetWindowTextLength(hwnd);
GetWindowText(hwnd, value.GetBuffer(size + 1), size + 1);
value.ReleaseBuffer();
return value;
}
示例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;
}
示例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);
}
}
}
}