using System;
using System.Runtime.InteropServices;
namespace TextColor1
{
class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput,
int wAttributes);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(uint nStdHandle);
public 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} I want to be nice today!",k);
}
// final setting
SetConsoleTextAttribute(hConsole, 236);
Console.WriteLine("Çıkmak için Enter tuşuna basın...");
Console.Read(); // wait
}
}
}
using System.Runtime.InteropServices;
namespace TextColor1
{
class MainClass
{
[DllImport("kernel32.dll")]
public static extern bool SetConsoleTextAttribute(IntPtr hConsoleOutput,
int wAttributes);
[DllImport("kernel32.dll")]
public static extern IntPtr GetStdHandle(uint nStdHandle);
public 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} I want to be nice today!",k);
}
// final setting
SetConsoleTextAttribute(hConsole, 236);
Console.WriteLine("Çıkmak için Enter tuşuna basın...");
Console.Read(); // wait
}
}
}
EKRAN GÖRÜNTÜSÜ
KAYNAK: http://www.bilgisayardershanesi.com/Y4888-konsol-ekraninda-renkli-yazi.html |
Hiç yorum yok:
Yorum Gönder