GetWindowTextA

GetWindowTextA將指定視窗的標題欄(如果有的話)的文字拷貝到緩衝區內。如果指定的視窗是一個控制項(control),那么該控制項的text屬性將被拷貝(到緩衝區)。但是,GetWindowText 不能取回其他程式中控制項的text。

功能,函式原型,參數,返回值,運行環境,

功能

Copies the text of the specified window's title bar (if it has one) into a buffer. If the specified window is a control, the text of the control is copied. However,GetWindowText cannot retrieve the text of a control in another application.

函式原型

int WINAPI GetWindowText(
_In_ HWND hWnd,
_Out_ LPTSTR lpString,
_In_ int nMaxCount
);

參數

hWnd [in]
Type: HWND
A handle to the window or control containing the text.
一個指向特定視窗或控制項的句柄。
lpString [out]Type: LPTSTR
The buffer that will receive the text. If the string is as long or longer than the buffer, the string is truncated and terminated with a null character.
一個用來接受文本的緩衝區。如果(取回的)字元串與緩衝區等長或者比緩衝區長,那么該字串會被截斷,並用NULL字元結束。
nMaxCount [in]Type: int
The maximum number of characters to copy to the buffer, including the null character. If the text exceeds this limit, it is truncated.
將要拷貝到緩衝區中的字元的最大個數,包括NULL字元。如果目標TEXT超出限制則會被截斷。

返回值

Type:
Type: int
類型:整型
If the function succeeds, the return value is the length, in characters, of the copied string, not including the terminating null character. If the window has no title bar or text, if the title bar is empty, or if the window or control handle is invalid, the return value is zero. To get extended error information, callGetLastError.
如果函式運行成功,返回值是不包含結尾NULL字元的字元串長度。如果指定的視窗(或控制項)沒有標題欄或者TEXT屬性,如果標題欄為空,又如果給定的句柄是無效的,那么返回值是0。想要獲得更多的錯誤信息,請調用GetLastError
This function cannot retrieve the text of an edit control in another application.
該函式不能取回其他程式中控制項的text。

運行環境

Minimum supported client
Windows 2000 Professional [desktop apps only]
Minimum supported server
Windows 2000 Server [desktop apps only]
Header
Winuser.h (include Windows.h)
Library
User32.lib
DLL
User32.dll
Unicode and ANSI names
GetWindowTextW (Unicode) and GetWindowTextA (ANSI)

相關詞條

熱門詞條

聯絡我們