L linfox Unregistered / Unconfirmed GUEST, unregistred user! 2006-02-23 #1 为了在一个在内存中运行的应用程序中安装消息处理钩子,必须找到该进程的主window句柄。用什么API函数可以找到呢?我现在只有应用程序名。
A Avalon Unregistered / Unconfirmed GUEST, unregistred user! 2006-02-23 #2 用spy ++ 确定你主窗体的类名<br>然后FindWindow
H hlfysj Unregistered / Unconfirmed GUEST, unregistred user! 2006-02-23 #3 hwnd := FindWindow(窗体类名,窗体名称));
L linfox Unregistered / Unconfirmed GUEST, unregistred user! 2006-02-23 #4 关键是用spy抓到的窗体类名是对应的窗口是唯一的吗?而窗体名是象IE一样,打开什么文件其caption也会跟着改变。所以findwindow()很难,可能要通过枚举进程,找到应用程序的进程,然后再找主window的句柄。但是我不知道用什么函数。谢谢各位DFW了。
关键是用spy抓到的窗体类名是对应的窗口是唯一的吗?而窗体名是象IE一样,打开什么文件其caption也会跟着改变。所以findwindow()很难,可能要通过枚举进程,找到应用程序的进程,然后再找主window的句柄。但是我不知道用什么函数。谢谢各位DFW了。
T Txh2005 Unregistered / Unconfirmed GUEST, unregistred user! 2006-02-23 #5 给你来一段[]<br>var<br> curwin, Desktop, len: integer; //当前窗口句柄,桌面句柄(也是一个句柄),窗体标题长度<br> // Style: longint; //窗体类别<br> str: array[0..100] of char;<br>begin<br> lst2.Clear;<br> curwin := 0;<br> Desktop := GetDesktopWindow;<br> repeat<br> curwin := findwindowex(Desktop, curwin, nil, nil); //找他的子窗体<br> len := GetWindowTextLength(curwin); //长度<br> if IsWindowVisible(curwin) //可见<br> and ((GetWindowLong(curwin, GWL_HWNDPARENT) = 0) or //是一级窗体<br> (HWND(GetWindowLong(curwin, GWL_HWNDPARENT)) = GetDesktopWindow))<br> and ((GetWindowLong(curwin, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)<br> then<br> begin<br> getwindowtext(curwin, str, 255);<br> // showmessage(str);<br> lst2.Items.Add(str);<br> end;<br> until curwin = 0;<br> curwin := 0;<br> Desktop := GetDesktopWindow;<br><br> lbl2.Caption := '应用程序:'+IntToStr(lst2.Items.Count);<br>end;
给你来一段[]<br>var<br> curwin, Desktop, len: integer; //当前窗口句柄,桌面句柄(也是一个句柄),窗体标题长度<br> // Style: longint; //窗体类别<br> str: array[0..100] of char;<br>begin<br> lst2.Clear;<br> curwin := 0;<br> Desktop := GetDesktopWindow;<br> repeat<br> curwin := findwindowex(Desktop, curwin, nil, nil); //找他的子窗体<br> len := GetWindowTextLength(curwin); //长度<br> if IsWindowVisible(curwin) //可见<br> and ((GetWindowLong(curwin, GWL_HWNDPARENT) = 0) or //是一级窗体<br> (HWND(GetWindowLong(curwin, GWL_HWNDPARENT)) = GetDesktopWindow))<br> and ((GetWindowLong(curwin, GWL_EXSTYLE) and WS_EX_TOOLWINDOW) = 0)<br> then<br> begin<br> getwindowtext(curwin, str, 255);<br> // showmessage(str);<br> lst2.Items.Add(str);<br> end;<br> until curwin = 0;<br> curwin := 0;<br> Desktop := GetDesktopWindow;<br><br> lbl2.Caption := '应用程序:'+IntToStr(lst2.Items.Count);<br>end;