Last active
December 24, 2022 06:25
-
-
Save pmttavara/17c2cfb5893b85f33ae35bef722ae681 to your computer and use it in GitHub Desktop.
Check whether the console is owned by the current process in Win32
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static bool terminal_belongs_to_self(void) { | |
DWORD pid = 0; GetWindowThreadProcessId(GetConsoleWindow(), &pid); | |
return pid == GetCurrentProcessId(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment