HWND FindWindow( LPCTSTR lpClassName, // pointer to class name LPCTSTR lpWindowName // pointer to window name ); ParameterslpClassNamePoints to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero. lpWindowNamePoints to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. Return ValuesIf the function succeeds, the return value is the 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 . See AlsoEnumWindows, FindWindowEx, GetClassName, GlobalAddAtom 这样找dim hnd as long hnd=findwindow(0,"另一个程序的窗体标题") 这就可以了
不好 意思 错了应该是Dim hnd As Long hnd=findwindow(vbNullString,"另一个程序的窗体标题")
但有时候我并不一定能得到hwnd
我这里有一个类似于SpyXX的例子,是源于《VB6编程高手》
如需要可以发给你!
LPCTSTR lpWindowName // pointer to window name
);
ParameterslpClassNamePoints to a null-terminated string that specifies the class name or is an atom that identifies the class-name string. If this parameter is an atom, it must be a global atom created by a previous call to the GlobalAddAtom function. The atom, a 16-bit value, must be placed in the low-order word of lpClassName; the high-order word must be zero. lpWindowNamePoints to a null-terminated string that specifies the window name (the window's title). If this parameter is NULL, all window names match. Return ValuesIf the function succeeds, the return value is the 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
. See AlsoEnumWindows, FindWindowEx, GetClassName, GlobalAddAtom
这样找dim hnd as long
hnd=findwindow(0,"另一个程序的窗体标题")
这就可以了
hnd=findwindow(vbNullString,"另一个程序的窗体标题")
谢谢,最好是有例子了
[email protected]
因为我不一定知道另一个应用程序的类是什么,所以光有findwindow不行
不过还是谢谢你
例子已收到,等我先调试,过回再结贴