Browse Source

Add system::runProcessAsync

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
82f32038ac
2 changed files with 20 additions and 0 deletions
  1. +5
    -0
      include/system.hpp
  2. +15
    -0
      src/system.cpp

+ 5
- 0
include/system.hpp View File

@@ -36,7 +36,12 @@ Shell injection is possible, so make sure the URL is trusted or hard coded.
May block, so open in a new thread.
*/
void openBrowser(const std::string &url);
/** Opens Explorer, Finder, etc at the folder location. */
void openFolder(const std::string &path);
/** Runs an executable without blocking.
The launched process will continue running if the current process is closed.
*/
void runProcessAsync(const std::string &path);


} // namespace system


+ 15
- 0
src/system.cpp View File

@@ -174,6 +174,21 @@ void openFolder(const std::string &path) {
}


void runProcessAsync(const std::string &path) {
#if defined ARCH_WIN
STARTUPINFO startupInfo;
PROCESS_INFORMATION processInfo;

std::memset(&startupInfo, 0, sizeof(startupInfo));
startupInfo.cb = sizeof(startupInfo);
std::memset(&processInfo, 0, sizeof(processInfo));

CreateProcessA(path.c_str(), NULL,
NULL, NULL, false, 0, NULL, NULL,
&startupInfo, &processInfo);
#endif
}


} // namespace system
} // namespace rack

Loading…
Cancel
Save