#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
HWND WINAPI GetConsoleWindow();
int main(int argc, char *argv[])
{
	HWND hwnd;
	HDC hdc;
	HPEN hpen;
	hwnd = GetConsoleWindow();
	hdc = GetDC(hwnd);
	system("color F0");
	system("cls");
	hpen = CreatePen(PS_SOLID, 1, RGB(255, 0, 0));
	SelectObject(hdc, hpen);
	MoveToEx(hdc, 20, 20, NULL);
	LineTo(hdc, 200, 300);
	DeleteObject(hpen);
	ReleaseDC(hwnd, hdc);
	getchar();
	return 0;
}
在控制台调用win32只要include相应的头文件即可
运行效果:

原文:https://www.cnblogs.com/wangxingzhou/p/10386977.html