■ 윈도우 텍스트를 구하는 방법을 보여준다.
▶ 예제 코드 (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 |
using System; using System.Runtime.InteropServices; using System.Text; #region 윈도우 텍스트 구하기 - GetWindowText(windowHandle) /// <summary> /// 윈도우 텍스트 구하기 /// </summary> /// <param name="windowHandle">윈도우 핸들</param> /// <returns>윈도우 텍스트</returns> public string GetWindowText(IntPtr windowHandle) { StringBuilder stringBuilder = new StringBuilder(100); GetWindowText(windowHandle, stringBuilder, 100); string windowText = stringBuilder.ToString(); return windowText; } #endregion #region 윈도우 텍스트 구하기 - GetWindowText(windowHandle, stringBuilder, maximumCount) /// <summary> /// 윈도우 텍스트 구하기 /// </summary> /// <param name="windowHandle">윈도우 핸들</param> /// <param name="stringBuilder">문자열 빌더</param> /// <param name="maximumCount">최대 카운트</param> /// <returns>윈도우 텍스트</returns> [DllImport("user32")] private static extern int GetWindowText(IntPtr windowHandle, StringBuilder stringBuilder, int maximumCount); #endregion |