findwindow(api)的具體用法

 

The FindWindow function retrieves a handle to the top-level window whose class name and window name match the

specified strings. This function does not search child windows. This function does not perform a case-sensitive

search.
FindWindow函數根據給定的窗體類名稱、窗體名稱的字符串搜索父窗體並返回其窗體句柄。這個函數並不搜索子窗體。這個函數並不

完成一個事件感知的搜索。

To search child windows, beginning with a specified child window, use the FindWindowEx function.
要搜索給定窗體的子窗體,使用FindWindowEx函數。

Syntax
語法

HWND FindWindow(
LPCTSTR lpClassName,
LPCTSTR lpWindowName
);

Parameters
參數

lpClassName
[in] Pointer to a null-terminated string that specifies the class name or a class atom created by a previous call to

the RegisterClass or RegisterClassEx function. The atom must be in the low-order word of lpClassName; the high-order

word must be zero.
[輸入]一個以零作爲終結符的字符串指針,給定窗體的類名稱或由先前執行RegisterClass或RegisterClassEx函數創建的類原子,類

原子的低位兩個字節必須是lpClassName參數,高位兩個字節必須是零。

If lpClassName points to a string, it specifies the window class name. The class name can be any name registered

with RegisterClass or RegisterClassEx, or any of the predefined control-class names.
如果lpClassName指針指向字符串,它就給定了窗體的類名稱。類名稱可以是RegisterClass或RegisterClassEx註冊的任意名稱,或

者是任何預先定義好的控件類名稱。

If lpClassName is NULL, it finds any window whose title matches the lpWindowName parameter.
如果lpClassName是空指針,函數將按照lpWindowName參數搜索所有窗體。


lpWindowName
[in] Pointer to a null-terminated string that specifies the window name (the window's title). If this parameter is

NULL, all window names match.
[輸入]一個以零作爲終結符的字符串指針,給定窗體名稱(標題)。如果這個參數是空指針,函數搜索時將忽略窗體名稱。


Return Value
函數返回值

If the function succeeds, the return value is a handle to the window that has the specified class name and window

name.
如果函數執行成功,返回值是一個給定的窗體類名稱和窗體名稱的窗體句柄。

If the function fails, the return value is NULL. To get extended error information, call GetLastError.
如果函數執行失敗,返回值爲零。執行GetLastError函數獲得更多的錯誤信息。

 

看懂了MSDN就知道了這個函數是查找父窗體句柄的。
比如現在你這個帖子的IE瀏覽器窗體,它的窗體類名稱是"IEFrame",窗體名稱就是"百度_vb吧_想問問findwindow(api)的具體用 法! - Microsoft Internet Explorer"。
所以現在這個窗體的句柄就這樣來獲得:

hwnd=FindWindow("IEFrame","百度_vb吧_想問問findwindow(api)的具體用法! - Microsoft Internet Explorer")
發佈了214 篇原創文章 · 獲贊 11 · 訪問量 27萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章