프로그래밍/C#

C#에서 콘솔 응용 프로그램을 숨기는 방법

뽀로로친구에디 2021. 9. 24. 10:43

 

C#에서 콘솔 응용 프로그램을 숨기는 방법

using System;
using System.Runtime.InteropServices;
using System.Threading;

namespace hideconsole
{
    class Program
    {
        [DllImport("Kernel32.dll")]
        private static extern IntPtr GetConsoleWindow();
        [DllImport("User32.dll")]
        private static extern bool ShowWindow(IntPtr hWnd, int cmdShow);
    
        static void Main(string[] args)
        {
            Console.WriteLine("아무키나 눌러주세요!!");
            Console.ReadKey();
            IntPtr hWnd = GetConsoleWindow();
            if(hWnd != IntPtr.Zero)
            {
                ShowWindow(hWnd, 0); // 숨기기 
                Thread.Sleep(5000); // 5초
                ShowWindow(hWnd, 1); // 보이기
            }
            Console.ReadKey();
        }
    }
}

 

https://youtu.be/xVkKiWEQURI

 

- YouTube

 

www.youtube.com