Домой Приложения Цветное консольное приложение: Справочник по C#

Цветное консольное приложение: Справочник по C#

493
0


using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices; // DllImport()

namespace ColorConsoleApplication1
{
class Program
{

[DllImport("kernel32.dll")]
public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput,
int wAttributes);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(uint nStdHandle);

static void Main(string[] args)
{
uint STD_OUTPUT_HANDLE = 0xfffffff5;
IntPtr hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
// increase k for more color options
for (int k = 1; k < 255; k++)
{
SetConsoleTextAttribute(hConsole, k);
Console.WriteLine("{0:d3}  www.CSharpSouresCode.net!", k);
}
// final setting
SetConsoleTextAttribute(hConsole, 236);

Console.WriteLine("Press Enter to exit ...");
Console.Read();  // wait
}
}
}

Цветное консольное приложение: Справочник по C#

0.00 (0%) 0 votes

ЧИТАТЬ ТАКЖЕ:  Запрет кнопки закрытия приложения: Справочник по C#

ОСТАВЬТЕ ОТВЕТ

Пожалуйста, введите ваш комментарий!
пожалуйста, введите ваше имя здесь