CustomString Sample: Demonstrates Custom Memory Allocators for CStringT
The CustomString sample shows how to use a custom memory allocator for CStringT to improve performance in a multithreaded application. The sample application replaces carriage return/line feed pairs in a set of text files with a single carriage return, processing multiple files simultaneously on different threads.
This sample code is intended to illustrate a concept, and it shows only the code that is relevant to that concept. It may not meet the security requirements for a specific environment, and it should not be used exactly as shown. We recommend that you add security and error-handling code to make your projects more secure and robust. Microsoft provides this sample code "AS IS" with no warranties.
To get samples and instructions for installing them:
To access samples from Visual Studio
On the Help menu, click Samples.
By default, these samples are installed in drive:\Program Files\Microsoft Visual Studio 10.0\Samples\.
- For the most recent version of this sample and a list of other samples, see Visual Studio Samples on the MSDN Web site.
Building and Running the Sample
To build and run this sample
Open the solution file CustomString.sln.
From the Build menu, click Build Solution.
To run the sample from a command prompt, type CustomString *.txt. The sample will find all files in the current directory with ".txt" as the file extension and will create a copy of each file with ".utxt" as the file extension. The new files will have all CR/LF pairs replaced with a single CR.
To run the sample from within Visual Studio, right-click the solution and click Properties on the shortcut menu. Under Configuration Properties. select Debugging, and set the command-line argument property to "*.txt" for the correct configuration.
Classes and Keywords
This sample uses the following classes:
IAtlStringMgr; CWin32Heap; CAtlStringMgr; CStringT
This sample uses the following keywords:
CBitmap::LoadBitmap; CEdit::Clear; CEdit::GetLineCount; CEdit::LineIndex; CEdit::LineLength; CEdit::ReplaceSel; CEdit::SetSel; CFileDialog::DoModal; CFileDialog::GetPathName; CGdiObject::DeleteObject; CSpinButtonCtrl::GetBuddy; CString::GetBufferSetLength; CString::GetLength; CString::Left; CString::LoadString; CString::ReleaseBuffer; CWinApp::LoadIcon; CWnd::GetClientRect; CWnd::GetWindowRect; CWnd::SetWindowPos; CWnd::SetWindowText; DeleteItem; CWnd::DestroyWindow; CWnd::EnableWindow; GetCursorPos; GetDlgItem; GetParent; GetWindowLong; GetWindowRect; InvalidateRect; LoadIcon; MAKELONG; MessageBeep; ReleaseCapture; ScreenToClient; SetCapture; SetWindowLong; SetWindowPos; UpdateWindow; WindowProc; mbstowcs; rand; srand; time; wsprintf