■ SetCurrentConsoleFontEx API 함수를 선언하는 방법을 보여준다.
▶ 예제 코드 (C#)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 |
using System; using System.Runtime.InteropServices; #region 현재 콘솔 폰트 설정하기 - SetCurrentConsoleFontEx(outputHandle, maximumWindow, info) /// <summary> /// 현재 콘솔 폰트 설정하기 /// </summary> /// <param name="outputHandle">출력 핸들</param> /// <param name="maximumWindow">최대 창 크기 글꼴 정보 여부</param> /// <param name="info">콘솔 폰트 정보 확장</param> /// <returns>처리 결과</returns> [DllImport("kernel32", SetLastError = true)] private static extern bool SetCurrentConsoleFontEx(IntPtr outputHandle, bool maximumWindow, ref CONSOLE_FONT_INFO_EX info); #endregion /// <summary> /// 좌표 /// </summary> [StructLayout(LayoutKind.Sequential)] public struct COORD { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// X /// </summary> public short X; /// <summary> /// Y /// </summary> public short Y; #endregion //////////////////////////////////////////////////////////////////////////////////////////////////// Constructor ////////////////////////////////////////////////////////////////////////////////////////// Public #region 생성자 - COORD(x, y) /// <summary> /// 생성자 /// </summary> /// <param name="x">X</param> /// <param name="y">Y</param> public COORD(short x, short y) { X = x; Y = y; } #endregion } /// <summary> /// LF_FACESIZE /// </summary> public const int LF_FACESIZE = 32; /// <summary> /// 콘솔 폰트 정보 확장 /// </summary> [StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)] public unsafe struct CONSOLE_FONT_INFO_EX { //////////////////////////////////////////////////////////////////////////////////////////////////// Field ////////////////////////////////////////////////////////////////////////////////////////// Public #region Field /// <summary> /// 크기 /// </summary> public uint Size; /// <summary> /// 폰트 /// </summary> public uint Font; /// <summary> /// 폰트 크기 /// </summary> public COORD FontSize; /// <summary> /// 폰트 패밀리 /// </summary> public int FontFamily; /// <summary> /// 폰트 가중치 /// </summary> public int FontWeight; /// <summary> /// 페이스명 /// </summary> public fixed char FaceName[LF_FACESIZE]; #endregion } |