MCPcopy Create free account
hub / github.com/NetHack/NetHack / GetConsoleHwnd

Function GetConsoleHwnd

sys/windows/windsys.c:450–474  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

448}
449
450static HWND
451GetConsoleHwnd(void)
452{
453 int iterations = 0;
454 HWND hwndFound = 0;
455 char OldTitle[1024], NewTitle[1024], TestTitle[1024];
456
457 /* Get current window title */
458 GetConsoleTitle(OldTitle, sizeof OldTitle);
459
460 (void) sprintf(NewTitle, "NETHACK%lld/%ld", GetTickCount64(),
461 GetCurrentProcessId());
462 SetConsoleTitle(NewTitle);
463
464 GetConsoleTitle(TestTitle, sizeof TestTitle);
465 while (strcmp(TestTitle, NewTitle) != 0) {
466 iterations++;
467 /* sleep(0); */
468 GetConsoleTitle(TestTitle, sizeof TestTitle);
469 }
470 hwndFound = FindWindow(NULL, NewTitle);
471 SetConsoleTitle(OldTitle);
472 /* printf("%d iterations\n", iterations); */
473 return hwndFound;
474}
475#endif /* 0 */
476#endif /* WIN32CON */
477#endif /* RUNTIME_PASTEBUF_SUPPORT */

Callers 1

GetConsoleHandleFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected