控制台程序单调的黑色底调,白色字给人一种压抑的感觉,但是系统是提供给我们
api来显示不同的颜色。下面是一段代码。
program Project1;
{$APPTYPE CONSOLE}
uses
SysUtils, Windows;
var
consolehwnd : THandle;
i : Integer;
begin
consolehwnd := GetStdHandle(STD_OUTPUT_HANDLE);//取得输出句柄- STD_INPUT_HANDLE输入
SetConsoleTitle('http://www.pggpjj.com');//设置console windowtitle
SetConsoleTextAttribute(consolehwnd,FOREGROUND_BLUE);//设置输出字体颜色--
Writeln('我是P哥!!');
SetConsoleTextAttribute(consolehwnd,FOREGROUND_RED);
Writeln('我的人生格言');
SetconsoleTextAttribute(consolehwnd,FOREGROUND_GREEN);
Writeln('自己的命运自己把握');
SetConsoleTextAttribute(consolehwnd,FOREGROUND_BLUE);
for i := 1 to 10 do
case i of
1: Writeln(' * ');
2: Writeln(' ***');
3: Writeln(' *****');
4: Writeln(' *******');
5: Writeln('[]D [] []\/[] []D');
6: Writeln(' *******');
7: Writeln(' *****');
8: Writeln(' ***');
9: Writeln(' *');
10:writeln('走自己的路让别人去说吧!');
end;
SetConsoleTextAttribute(consolehwnd,RGB(100,200,255));//这是底色
Writeln('--潘国光---浙江海洋学院--A02电气(1)-QQ:68848864');
Readln;
end.
----------------
自己可以看一下,自己用一下面的api
function SetConsoleActiveScreenBuffer; external kernel32 name 'SetConsoleActiveScreenBuffer';
function SetConsoleCP; external kernel32 name 'SetConsoleCP';
function SetConsoleCtrlHandler; external kernel32 name 'SetConsoleCtrlHandler';
function SetConsoleCursorInfo; external kernel32 name 'SetConsoleCursorInfo';
function SetConsoleCursorPosition; external kernel32 name 'SetConsoleCursorPosition';
function SetConsoleMode; external kernel32 name 'SetConsoleMode';
function SetConsoleOutputCP; external kernel32 name 'SetConsoleOutputCP';
function SetConsoleScreenBufferSize; external kernel32 name 'SetConsoleScreenBufferSize';
function SetConsoleTextAttribute; external kernel32 name 'SetConsoleTextAttribute';
function SetConsoleTitle; external kernel32 name 'SetConsoleTitleA';
function SetConsoleTitleA; external kernel32 name 'SetConsoleTitleA';
function SetConsoleTitleW; external kernel32 name 'SetConsoleTitleW';
function SetConsoleWindowInfo; external kernel32 name 'SetConsoleWindowInfo';
本文地址:http://com.8s8s.com/it/it4640.htm