.NET/Windows API for .NET

GetWindowTextLength - 특정 Window의 제목문자열 크기구하기

클리엘 2019. 8. 6. 15:59
728x90

GetWindowTextLength함수는 지정한 Window의 제목문자열 크기값을 반환합니다.

Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Integer) As Integer

▶VB.NET 선언

[DllImport("user32")]
public static extern int GetWindowTextLength(int hwnd);

▶C# 선언


GetWindowTextLength함수의 인수로는 제목문자열 크기를 구하고자할 Window의 Handle을 전달해 주기만 하면 됩니다.

예를 들어 현재 실행중인 From Window의 제목문자열 크기를 구하려면 다음과 같이 함수를 호출하면 됩니다.

GetWindowTextLength(Me.Handle)

▶VB.NET 호출

GetWindowTextLength((int)this.Handle);

▶C# 호출


GetWindowTextLength함수는 실행에 실패하는 경우 0을 반환합니다.

728x90