如何遍历桌面上的所有窗口,一定给分

tele 2002-01-29 04:56:54
我想察看桌面是否打开了word,最好有源代码
...全文
271 10 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
skydg 2002-01-29
  • 打赏
  • 举报
回复
收藏
shawls 2002-01-29
  • 打赏
  • 举报
回复
+

使用回调枚举窗体!
tele 2002-01-29
  • 打赏
  • 举报
回复
结账,给分
jett 2002-01-29
  • 打赏
  • 举报
回复
收藏
playyuer 2002-01-29
  • 打赏
  • 举报
回复
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q183009
HOWTO: Enumerate Windows Using the WIN32 API (Q183009)
uguess 2002-01-29
  • 打赏
  • 举报
回复
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10
Const gcClassnameMSWord = "OpusApp"
Const gcClassnameMSExcel = "XLMAIN"
Const gcClassnameMSIExplorer = "IEFrame"
Const gcClassnameMSVBasic = "wndclass_desked_gsk"
Const gcClassnameNotePad = "Notepad"
Const gcClassnameMyVBApp = "ThunderForm"
Private Sub Form_Load()
'KPD-Team 1998
'URL: http://www.allapi.net/
'E-Mail: KPDTeam@Allapi.net
Dim WinWnd As Long, Ret As String, RetVal As Long, lpClassName As String
'Ask for a Window title
Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
'Search the window
WinWnd = FindWindow(vbNullString, Ret)
If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
'Show the window
ShowWindow WinWnd, SW_SHOWNORMAL
'Create a buffer
lpClassName = Space(256)
'retrieve the class name
RetVal = GetClassName(WinWnd, lpClassName, 256)
'Show the classname
MsgBox "Classname: " + Left$(lpClassName, RetVal)
'Post a message to the window to close itself
PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub
Azi03 2002-01-29
  • 打赏
  • 举报
回复
HWND BlurFindWindow(char* BlurTitleText)
{
HWND CurWindowHandle=GetTopWindow(NULL);
do
{
char TitleText[500];
GetWindowText(CurWindowHandle,TitleText,500);
if(!strncmp(TitleText,BlurTitleText,strlen(BlurTitleText)))
return CurWindowHandle;
}while((CurWindowHandle=GetNextWindow(CurWindowHandle,GW_HWNDNEXT))!=NULL);
return NULL;
}
这是一个用C编的函数,你可以参考,都用API,一样
ferrytang 2002-01-29
  • 打赏
  • 举报
回复
Dim hToolbar As Long
'获的工具条窗口句柄
hToolbar = FindWindowEx(tb.hwnd,0&,"ToolBarWindow32",vbNullString)
你只要把ToolBarWindow32换成word窗体的类就可以了!
tele 2002-01-29
  • 打赏
  • 举报
回复
你怎么吧msdn翻译了一下
有没有程序?
ferrytang 2002-01-29
  • 打赏
  • 举报
回复
FindWindowEx

VB声明
Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
说明
在窗口列表中寻找与指定条件相符的第一个子窗口
返回值
Long,找到的窗口的句柄。如未找到相符窗口,则返回零。会设置GetLastError
参数表
参数 类型及说明
hWnd1 Long,在其中查找子的父窗口。如设为零,表示使用桌面窗口(通常说的顶级窗口都被认为是桌面的子窗口,所以也会对它们进行查找)
hWnd2 Long,从这个窗口后开始查找。这样便可利用对FindWindowEx的多次调用找到符合条件的所有子窗口。如设为零,表示从第一个子窗口开始搜索
lpsz1 String,欲搜索的类名。零表示忽略
lpsz2 String,欲搜索的类名。零表示忽略

Top

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧