Skip to content

Instantly share code, notes, and snippets.

@pmttavara
Last active December 24, 2022 06:25
Show Gist options
  • Save pmttavara/17c2cfb5893b85f33ae35bef722ae681 to your computer and use it in GitHub Desktop.
Save pmttavara/17c2cfb5893b85f33ae35bef722ae681 to your computer and use it in GitHub Desktop.
Check whether the console is owned by the current process in Win32
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