-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathwconsole.c
More file actions
64 lines (49 loc) · 1.46 KB
/
Copy pathwconsole.c
File metadata and controls
64 lines (49 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#define WIN32_LEAN_AND_MEAN
#include <windows.h>
#include <wconsole.h>
#pragma comment(lib, "kernel32")
EXTERN_C void clreol()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
LPSTR cBlankStr;
DWORD dwWriteLength;
if (!GetConsoleScreenBufferInfo(hConOut, &csbi))
return;
dwWriteLength = csbi.dwSize.X - csbi.dwCursorPosition.X;
cBlankStr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dwWriteLength);
if (cBlankStr == (LPSTR)NULL)
return;
FillMemory(cBlankStr, dwWriteLength, ' ');
WriteConsoleOutputCharacter(hConOut, cBlankStr, dwWriteLength,
csbi.dwCursorPosition, &dwWriteLength);
HeapFree(GetProcessHeap(), 0, (LPVOID)cBlankStr);
}
EXTERN_C void gotoxy(SHORT x, SHORT y)
{
COORD coord;
coord.X = x-1;
coord.Y = y-1;
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
}
EXTERN_C void clrscr()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
HANDLE hConOut = GetStdHandle(STD_OUTPUT_HANDLE);
DWORD dwConSize;
LPSTR lpStr;
DWORD c;
COORD coord;
if (!GetConsoleScreenBufferInfo(hConOut, &csbi))
return;
coord.X = 0;
coord.Y = 0;
dwConSize = csbi.dwSize.X * csbi.dwSize.Y;
lpStr = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dwConSize);
c = dwConSize;
while (c--)
lpStr[c] = ' ';
WriteConsoleOutputCharacter(hConOut, lpStr, dwConSize, coord, &dwConSize);
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord);
HeapFree(GetProcessHeap(), 0, (LPVOID)lpStr);
}