本文整理汇总了C++中CString::AppendChar方法的典型用法代码示例。如果您正苦于以下问题:C++ CString::AppendChar方法的具体用法?C++ CString::AppendChar怎么用?C++ CString::AppendChar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CString
的用法示例。
在下文中一共展示了CString::AppendChar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: CreateMultipleDirectory
//////////////////////////////////////////////////////////////////////////
// 全局函数,创建多级目录
bool CreateMultipleDirectory(LPCTSTR szPath)
{
CString strDir(szPath); // 存放要创建的目录字符串
// 确保以'\'结尾以创建最后一个目录
if (strDir.GetAt(strDir.GetLength()-1)!=_T('\\'))
{
strDir.AppendChar(_T('\\'));
}
std::vector<CString> vPath;// 存放每一层目录字符串
CString strTemp;// 一个临时变量,存放目录字符串
bool bSuccess = false;// 成功标志
// 遍历要创建的字符串
for (int i=0;i<strDir.GetLength();++i)
{
if (strDir.GetAt(i) != _T('\\'))
{// 如果当前字符不是'\\'
strTemp.AppendChar(strDir.GetAt(i));
}
else
{// 如果当前字符是'\\'
vPath.push_back(strTemp);// 将当前层的字符串添加到数组中
strTemp.AppendChar(_T('\\'));
}
}
// 遍历存放目录的数组,创建每层目录
std::vector<CString>::const_iterator vIter;
for (vIter = vPath.begin(); vIter != vPath.end(); vIter++)
{
// 如果CreateDirectory执行成功,返回true,否则返回false
bSuccess = CreateDirectory(*vIter, NULL) ? true : false;
}
return bSuccess;
}
示例2: CopyFolder
// BrainUtil::CopyFolder(_T("C:\\srcFolder\"), _T("C:\\destFolder\\"));
// BrainUtil::CopyFolder(_T("C:\\srcFolder"), _T("C:\\newFolderRoot\\newFolder\\destFolder"));
// The directory tree will be created by xcopy if the parent of the dest doesn't exist.
bool BrainUtil::CopyFolder(const CString& srcFolderFullName, const CString& destFolderFullName)
{
if(!DoesFileorFolderExist(srcFolderFullName))
return false;
CString src = srcFolderFullName;
WCHAR lastChar = src.GetAt(src.GetLength() - 1);
if(lastChar != _T('\\'))
src.AppendChar(_T('\\'));
src.Append(_T("*.*")); // Add the widechar, change the format to be like C:\srcFolder\*.*
CString dest = destFolderFullName;
// If the last char isn't '\', a dialog will pop up to specify if the name is file or folder.
// Add the ending '\'. change the format to be like C:\destFolder\
lastChar = dest.GetAt(dest.GetLength() - 1);
if(lastChar != _T('\\'))
dest.AppendChar(_T('\\'));
CString cmd;
cmd.Format(_T("xcopy \"%s\" \"%s\" /E /C /R /Q /Y"), src.GetBuffer(), dest.GetBuffer());
int ret = _wsystem(cmd.GetBuffer());
DATA_ASSERT(0 == ret);
bool bSucc = DoesFileorFolderExist(destFolderFullName) && 0 == ret;
return bSucc;
}
示例3: DoPromptFileName
BOOL CDocManager::DoPromptFileName( CString &fileName, UINT nIDSTitle, DWORD lFlags,
BOOL bOpenFileDialog, CDocTemplate *pTemplate )
/*********************************************************************************/
{
CString strTitle;
strTitle.LoadString( nIDSTitle );
CString strFilter;
CString strExt;
CString strDocString;
LPCTSTR lpszDefExt = NULL;
if( pTemplate != NULL ) {
if( pTemplate->GetDocString( strExt, CDocTemplate::filterExt ) &&
!strExt.IsEmpty() ) {
ASSERT( strExt.GetLength() >= 2 );
ASSERT( strExt[0] == _T('.') );
lpszDefExt = (LPCTSTR)strExt + 1;
if( pTemplate->GetDocString( strDocString, CDocTemplate::filterName ) &&
!strDocString.IsEmpty() ) {
strFilter += strDocString;
strFilter.AppendChar( _T('\0') );
strFilter.AppendChar( _T('*') );
strFilter += strExt;
strFilter.AppendChar( _T('\0') );
}
}
} else {
POSITION position = m_templateList.GetHeadPosition();
while( position != NULL ) {
pTemplate = (CDocTemplate *)m_templateList.GetNext( position );
ASSERT( pTemplate != NULL );
if( pTemplate->GetDocString( strDocString, CDocTemplate::filterName ) &&
pTemplate->GetDocString( strExt, CDocTemplate::filterExt ) &&
!strDocString.IsEmpty() && !strExt.IsEmpty() ) {
ASSERT( strExt.GetLength() >= 2 );
ASSERT( strExt[0] == _T('.') );
strFilter += strDocString;
strFilter.AppendChar( _T('\0') );
strFilter.AppendChar( _T('*') );
strFilter += strExt;
strFilter.AppendChar( _T('\0') );
}
}
}
strDocString.LoadString( AFX_IDS_ALLFILTER );
strFilter += strDocString;
strFilter.AppendChar( _T('\0') );
strFilter += _T("*.*");
strFilter.AppendChar( _T('\0') );
CFileDialog dlg( bOpenFileDialog, lpszDefExt, NULL,
lFlags | OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, strFilter,
AfxGetMainWnd() );
dlg.m_ofn.lpstrTitle = strTitle;
if( dlg.DoModal() != IDOK ) {
return( FALSE );
}
fileName = dlg.GetFileName();
return( TRUE );
}
示例4: MoveFile
//
// MoveFile
//
// Move file(s)
//
HRESULT CLevelZapContextMenuExt::MoveFile(const HWND p_hParentWnd,
CString p_Path,
CString p_FolderTo) const {
if (p_Path.IsEmpty()) return S_OK;
SHFILEOPSTRUCT fileOpStruct = {0};
fileOpStruct.hwnd = p_hParentWnd;
fileOpStruct.wFunc = FO_MOVE;
p_Path.AppendChar(L'\0'); fileOpStruct.pFrom = p_Path;
p_FolderTo.AppendChar(L'\0'); fileOpStruct.pTo = p_FolderTo;
fileOpStruct.fFlags = FOF_MULTIDESTFILES | FOF_ALLOWUNDO | FOF_SILENT;
if (p_hParentWnd == 0) fileOpStruct.fFlags |= (FOF_NOCONFIRMATION | FOF_NOERRORUI);
int hRes = SHFileOperation(&fileOpStruct);
if (fileOpStruct.fAnyOperationsAborted) hRes = E_ABORT;
Util::OutputDebugStringEx(L"Move 0x%08x | %s -> %s\n", hRes, p_Path, p_FolderTo);
return hRes;
}
示例5: SerGet
void CIni::SerGet(bool bGet, WORD *ar, int nCount, LPCTSTR strEntry, LPCTSTR strSection/*=NULL*/, DWORD Default/* = 0*/)
{
if(nCount > 0) {
CString strBuffer;
if(bGet) {
strBuffer = GetString(strEntry, _T(""), strSection);
CString strTemp;
int nOffset = 0;
for(int i = 0; i < nCount; i++) {
nOffset = Parse(strBuffer, nOffset, strTemp);
if(strTemp.GetLength() == 0)
ar[i] = (WORD)Default;
else
ar[i] = (WORD)_tstoi(strTemp);
}
} else {
CString strTemp;
strBuffer.Format(_T("%d"), ar[0]);
for(int i = 1; i < nCount; i++) {
strTemp.Format(_T("%d"), ar[i]);
strBuffer.AppendChar(_T(','));
strBuffer.Append(strTemp);
}
WriteString(strEntry, strBuffer, strSection);
}
}
}
示例6: CodePassword
CString CodePassword(LPCTSTR decrypted)
{
CString crypted;
char cDecrypted[256] = { 0 };
strcpy(cDecrypted, CT2A(decrypted));
char *p = cDecrypted;
while (*p != '\0')
{
for (int i = 0; i < 256; i++)
{
if (*p == CodeBook[i])
{
TCHAR code[3] = {0};
wsprintf((LPWSTR)code, _T("%02x"), i);
crypted.AppendChar(code[0]);
crypted.AppendChar(code[1]);
break;
}
}
p++;
}
return crypted;
}
示例7: OnBnClickedOk
void CSubmoduleUpdateDlg::OnBnClickedOk()
{
CResizableStandAloneDialog::UpdateData(TRUE);
m_PathList.clear();
CString selected;
for (int i = 0; i < m_PathListBox.GetCount(); ++i)
{
if (m_PathListBox.GetSel(i))
{
if (!selected.IsEmpty())
selected.AppendChar(L'|');
CString text;
m_PathListBox.GetText(i, text);
m_PathList.push_back(text);
selected.Append(text);
}
}
m_regPath = selected;
m_regInit = m_bInit;
m_regRecursive = m_bRecursive;
m_regForce = m_bForce;
m_regRemote = m_bRemote;
m_regNoFetch = m_bNoFetch;
m_regMerge = m_bMerge;
m_regRebase = m_bRebase;
CResizableStandAloneDialog::OnOK();
}
示例8: SetFileModifiedFlag
void CFileView::SetFileModifiedFlag(BOOL bFlag)
{
if (m_bModifiedFlag == bFlag)
{
return;
}
m_bModifiedFlag = bFlag;
HTREEITEM hItem = m_wndFileView.GetSelectedItem();
HTREEITEM hParentItem = hItem;
while (m_wndFileView.GetParentItem(hParentItem))
{
hParentItem = m_wndFileView.GetParentItem(hParentItem);
}
CString strText = m_wndFileView.GetItemText(hParentItem);
if (bFlag)
{
strText.AppendChar('*');
}
else
{
strText.Delete(strText.GetLength() - 1);
}
m_wndFileView.SetItemText(hParentItem, strText);
}
示例9: InitInstance
BOOL CAddonUpdaterApp::InitInstance()
{
// InitCommonControlsEx() is required on Windows XP if an application
// manifest specifies use of ComCtl32.dll version 6 or later to enable
// visual styles. Otherwise, any window creation will fail.
INITCOMMONCONTROLSEX InitCtrls;
InitCtrls.dwSize = sizeof(InitCtrls);
// Set this to include all the common control classes you want to use
// in your application.
InitCtrls.dwICC = ICC_WIN95_CLASSES;
InitCommonControlsEx(&InitCtrls);
CWinApp::InitInstance();
AfxEnableControlContainer();
// Create the shell manager, in case the dialog contains
// any shell tree view or shell list view controls.
CShellManager *pShellManager = new CShellManager;
if (!GetWOWPath().IsEmpty())
{
CAddonUpdaterDlg dlg;
m_pMainWnd = &dlg;
INT_PTR nResponse = dlg.DoModal();
if (nResponse == IDOK)
{
// TODO: Place code here to handle when the dialog is
// dismissed with OK
}
else if (nResponse == IDCANCEL)
{
// TODO: Place code here to handle when the dialog is
// dismissed with Cancel
}
}
else
{
MessageBox(NULL, _T("δÕÒµ½Ä§ÊÞÊÀ½ç°²×°Â·¾¶¡£"), _T("´íÎó"), MB_ICONEXCLAMATION | MB_OK);
}
// Delete the shell manager created above.
if (pShellManager != NULL)
{
delete pShellManager;
}
SHFILEOPSTRUCT op = {0};
op.wFunc = FO_DELETE;
CString strPath = theApp.GetTempPath();
strPath.AppendChar(_T('\0'));
op.pFrom = strPath.GetString();
op.fFlags = FOF_NOCONFIRMATION;
SHFileOperation(&op);
// Since the dialog has been closed, return FALSE so that we exit the
// application, rather than start the application's message pump.
return FALSE;
}
示例10: RemoveDirectory
BOOL CUtils::RemoveDirectory( LPCTSTR lpszDirectoryPath )
{
if(!::PathFileExists(lpszDirectoryPath))
return TRUE;
if(::PathIsRoot(lpszDirectoryPath))
{
ATLASSERT(FALSE);
return FALSE;
}
CString strDirPathTemp = lpszDirectoryPath;
strDirPathTemp.AppendChar(_T('\0'));
SHFILEOPSTRUCT FileOp;
ZeroMemory((void*)&FileOp, sizeof(SHFILEOPSTRUCT));
FileOp.wFunc = FO_DELETE;
FileOp.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI | FOF_NOCONFIRMMKDIR;
FileOp.pFrom = strDirPathTemp;
FileOp.pTo = NULL;
return SHFileOperation(&FileOp) == 0;
}
示例11: GetFunctionName
HRESULT StackFrame::GetFunctionName(
FRAMEINFO_FLAGS flags,
UINT radix,
BSTR* funcName )
{
_ASSERT( funcName != NULL );
HRESULT hr = S_OK;
CString fullName;
if ( (flags & FIF_FUNCNAME_MODULE) != 0 )
{
if ( mModule != NULL )
{
CComBSTR modNameBstr;
mModule->GetName( modNameBstr );
fullName.Append( modNameBstr );
fullName.AppendChar( L'!' );
}
}
hr = AppendFunctionNameWithSymbols( flags, radix, fullName );
if ( FAILED( hr ) )
{
hr = AppendFunctionNameWithAddress( flags, radix, fullName );
if ( FAILED( hr ) )
return hr;
}
*funcName = fullName.AllocSysString();
return hr;
}
示例12: WincredExists
static bool WincredExists()
{
CString path = g_Git.ms_LastMsysGitDir;
if (g_Git.ms_LastMsysGitDir.Right(1) != _T("\\"))
path.AppendChar(_T('\\'));
path.Append(_T("..\\libexec\\git-core\\git-credential-wincred.exe"));
return !!PathFileExists(path);
}
示例13: BuildCmdLine
void BuildCmdLine()
{
const CPath *appPath = config.GetAppPath();
const CString *args = config.GetAppArgs();
cmdLine = static_cast<CString>(*appPath);
cmdLine.AppendChar(L' ');
cmdLine.Append(*args);
}
示例14: BYTE2BitsCString
CString BYTE2BitsCString(BYTE d)
{
CString str;
for(unsigned char mask=0x80;mask!=0;mask>>=1)
str.AppendChar(d&mask ? '1' : '0');
return str;
}
示例15: AppendStringResource
static void AppendStringResource(CString& text, UINT resouceID)
{
CString temp;
temp.LoadString(resouceID);
text.AppendChar(L'\n');
text.AppendChar(L'\n');
text.Append(temp);
}