dcsimg
Results 1 to 1 of 1

Thread: Cross-Platform Process Information Library (UTF-8 Support)

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2018
    Posts
    16

    Cross-Platform Process Information Library (UTF-8 Support)

    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 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 (unavailable in macOS)
    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
    Last edited by Samuel Venable; May 21st, 2020 at 06:30 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width