voidFork(intnLength){ CStringData* pOldData = GetData(); intnOldLength = pOldData->nDataLength; //分配新的缓冲区 CStringData* pNewData = pOldData->pStringMgr->Clone()->Allocate( nLength,sizeof( XCHAR ) ); //复制字符 intnCharsToCopy = ((nOldLength < nLength) ? nOldLength : ...
CStringformatForSingleLine(LPCTSTR szIn,charcCommentChar){ CString s;size_tlength =strlen(szIn);char* x = s.GetBufferSetLength(length+1);constchar* p = szIn;while(*p) {if(*p=='\r'|| *p=='\n') {if(*(x-1) !=' ')// don't want more than one space to appear*(x++) ='...
在使用CString::GetBuffer()时遇到了一个问题,代码如下: Cstring sPath; GetPrivateProfileString("Drivers","Type",sPath.GetBuffer(MAX_PATH),MAX_PATH,iniPath); sPath.ReleaseBuffer(); int pos = sPath.Find("\\"); Cstring type = sPath.Left(pos); 经过调试,发现sPath的值为ak\ddd.dll,pos=2,但是t...
声明LPTSTR GetBufferSetLength(int nNewLength);函数用于调整CString对象中的字符缓冲区大小。该函数接收一个整型参数nNewLength,表示要调整的字符缓冲区的精确大小(以字符为单位)。函数执行后返回一个LPTSTR指针,指向调整后大小的字符缓冲区。此缓冲区是null-terminated的,表示字符串以空字符结束。返回的...
CString str; LPTSTR pstr = str.GetBufferSetLength(3); pstr[0] = 'I'; pstr[1] = 'c'; pstr[2] = 'e'; // No need for trailing zero or call to ReleaseBuffer() // because GetBufferSetLength() set it for us! str += _T(" hockey is best!"); ...
CString csStr; LPTSTR lpsz = csStr.GetBufferSetLength(100); lpsz[0] = 'a'; lpsz[1] = 'b'; lpsz[2] = '\0'; int nLength = csStr.GetLength(); /* n的值还是为100 */
CString csStr; LPTSTR lpsz = csStr.GetBufferSetLength(100); lpsz[0] = 'a'; lpsz[1] = 'b'; lpsz[2] = '\0'; int nLength = csStr.GetLength(); /* n的值还是为100 */ 本文转自jazka 51CTO博客,原文链接:http://blog.51cto.com/jazka/188202,如需转载请自行联系原作者 ...
CStringA commonDirA;intlength = (int)fread(commonDirA.GetBufferSetLength(size),sizeof(char), size, pFile); commonDirA.ReleaseBuffer(length); CString commonDir = CUnicodeUtils::GetUnicode(commonDirA); commonDir.TrimRight(L"\r\n");
CString str; LPTSTR pstr = str.GetBufferSetLength(3); pstr[0] = 'I'; pstr[1] = 'c'; pstr[2] = 'e'; // No need for trailing zero or call to ReleaseBuffer() // because GetBufferSetLength() set it for us! str += _T(" hockey is best!"); ...