SpiecsEngine
 
Loading...
Searching...
No Matches

◆ OpenProcess()

bool Spices::ProcessLibrary::OpenProcess ( const char * processPath,
const char * commandLine = "" )
static

Open a Process with command.

Parameters
[in]processPathProcess Path.
[in]commandLineCommands.
Returns
Returns true if Open Process Successfully.

Definition at line 16 of file ProcessLibrary.cpp.

17 {
19
20 STARTUPINFO StartInfo;
21 PROCESS_INFORMATION info;
22
23 ZeroMemory(&StartInfo, sizeof(StartInfo));
24 StartInfo.cb = sizeof(STARTUPINFO);
25 ZeroMemory(&info, sizeof(PROCESS_INFORMATION));
26
27 const std::wstring path = StringLibrary::CharToWChar(processPath);
28 const std::wstring command = StringLibrary::CharToWChar(commandLine);
29
30 if (!CreateProcess(
31 path.c_str(), // Process Name
32 const_cast<wchar_t*>(command.c_str()), // Command line
33 nullptr, // Process handle not inheritable
34 nullptr, // Thread handle not inheritable
35 FALSE, // Set handle inheritance to FALSE
36 NORMAL_PRIORITY_CLASS, // No creation flags
37 nullptr, // Use parent's environment block
38 nullptr, // Use parent's starting directory
39 &StartInfo, // Pointer to STARTUP INFO structure
40 &info // Pointer to PROCESS_INFORMATION structure
41 ))
42 {
43 std::stringstream ss;
44 ss << "Process: " << processPath << " Open Failed";
45
46 SPICES_CORE_WARN(ss.str());
47 return false;
48 }
49
50 return true;
51 }
#define SPICES_PROFILE_ZONE
static std::wstring CharToWChar(const char *c)
Transform char to wide char.

References Spices::StringLibrary::CharToWChar().

Referenced by Spices::NsightPerfGPUProfilerOneshotCollection::EndFrame(), Spices::ImguiConsole::OnRender(), and SpicesTest::TEST().