Too much code to fit the character limit, so I'll just be linking to the repository on GitHub:
https://github.com/time-killer-games...sions/ProcInfo
Features included are documented below:
data types
Code:typedef DWORD process_t; // Win32-specific process identifier typedef pid_t process_t; // POSIX-specific process identifier typedef unsigned long long window_t; // cast from window handle typedef string wid_t; // window identifier - to_string from window_t
functions
Code:// Execute process, returns process id process_t process_execute(string command); // Execute process outside main thread void process_execute_async(string command); // Return previous executed process id process_t process_previous(); // Evaluate last process output string string process_evaluate(); // Clears previous process id executed void process_clear_pid(); // Clears previous process output text void process_clear_out(); // Get process id from current process process_t pid_from_self(); // Parent process id from this process process_t ppid_from_self(); // Get executable path from process id string path_from_pid(process_t pid); // Get exe parent path from process id string dir_from_pid(process_t pid); // Get executable name from process id string name_from_pid(process_t pid); // Check for existence from process id bool pid_exists(process_t pid); // Check existence for given window id bool wid_exists(wid_t wid); // Kill an application from process id bool pid_kill(process_t pid); // Return window handle from window id window_t window_from_wid(wid_t wid); // Return window id from window handle wid_t wid_from_window(window_t window); // Get owner process id from window id process_t pid_from_wid(wid_t wid); // Return strings for every process id string pids_enum(bool trim_dir, bool trim_empty); // Get parent process id of process id process_t ppid_from_pid(process_t pid); // Get list of process ids from parent string pids_from_ppid(process_t ppid); // Get window id from frontmost window wid_t wid_from_top(); // Get process id from topmost process process_t pid_from_top(); // Bring window id to frontmost window void wid_to_top(wid_t wid); // Add a parent window id to window id void wid_set_pwid(wid_t wid, wid_t pwid);
It's hosted in the same repository as my C++17 std::filesystem library, for those who might be interested in checking that out as well. No credit needed. Removing the credits header, if you want, and also, re-licensing the code to suit your needs are both permitted.
Samuel




Reply With Quote