|
|
1.1 root 1: #include <windows.h>
2: #include <stdio.h>
3: #include "console.h"
4:
5: /*********************************************************************
6: * FUNCTION: demoAllocFree(HANDLE hConOld, HANDLE *hConOut) *
7: * *
8: * PURPOSE: demonstrate FreeConsole & AllocConsole. Free the console *
9: * and allocate a new one *
10: * *
11: * INPUT: the current console output handle and a temporary 'scratch' *
12: * console handle *
13: *********************************************************************/
14:
15: void demoAllocFree(HANDLE hConOld, HANDLE *hConOut)
16: {
17: BOOL bSuccess;
18:
19: setConTitle(__FILE__);
20: myPuts(hConOld, "Let's free the current console with FreeConsole. It will\n"
21: "disappear for 3 seconds, then we'll allocate a new one.\n"
22: "with AllocConsole. Hit return to continue...");
23: myGetchar();
24: bSuccess = FreeConsole();
25: if (!bSuccess)
26: Beep(600, 500); /* can't output an error message now! */
27: Sleep(3000);
28: bSuccess = AllocConsole();
29: if (!bSuccess)
30: Beep(600, 500);
31: *hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
32: /* set our console text attribute */
33: bSuccess = SetConsoleTextAttribute(*hConOut, FOREGROUND_CYAN);
34: PERR(bSuccess, "SetConsoleTextAttribute");
35: myPuts(*hConOut, "This is a new console that we've allocated with AllocConsole.");
36: Sleep(2000);
37: /* must refresh the screen since we've replaced the console */
38: showConAPIs(*hConOut);
39: return;
40: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.