本文整理汇总了C++中TStr::CloneCStr方法的典型用法代码示例。如果您正苦于以下问题:C++ TStr::CloneCStr方法的具体用法?C++ TStr::CloneCStr怎么用?C++ TStr::CloneCStr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TStr
的用法示例。
在下文中一共展示了TStr::CloneCStr方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
TEST(TStr, CloneCStr) {
const TStr Str = "abcdef";
const TStr Empty = "";
char* StrClone = Str.CloneCStr();
char* EmptyClone = Empty.CloneCStr();
EXPECT_EQ(Str, StrClone);
EXPECT_EQ(Empty, EmptyClone);
}
示例2: ExeProc
bool TSysProc::ExeProc(const TStr& ExeFNm, TStr& ParamStr){
STARTUPINFO si;
PROCESS_INFORMATION pi;
ZeroMemory(&si, sizeof(si));
si.cb=sizeof(si);
ZeroMemory(&pi, sizeof(pi));
char * ParamStrCopy = ParamStr.CloneCStr();
// Start the child process.
BOOL Ok=CreateProcess(
ExeFNm.CStr(), // module name
ParamStrCopy, // patameters
NULL, // Process handle not inheritable.
NULL, // Thread handle not inheritable.
FALSE, // Set handle inheritance to FALSE.
0, // No creation flags.
NULL, // Use parent's environment block.
NULL, // Use parent's starting directory.
&si, // Pointer to STARTUPINFO structure.
&pi); // Pointer to PROCESS_INFORMATION structure.
delete[] ParamStrCopy;
if (Ok){
// Wait until child process exits.
WaitForSingleObject( pi.hProcess, INFINITE );
// Close process and thread handles.
CloseHandle( pi.hProcess );
CloseHandle( pi.hThread );
return true;
} else {
return false;
}
}