Dim pid     As Long
pid = Shell("C:\Documents and Settings\Administrator\桌面\工程1.exe", vbNormalFocus)
Dim mhwnd     As Long   '你要找的窗口句柄
mhwnd = InstanceToWnd(pid)
这是我在论坛考的
运行的时候提示函数未定义是怎麽回事啊
查api函数声明是还没有这个函数

解决方案 »

  1.   

    http://social.msdn.microsoft.com/Forums/en-US/vbgeneral/thread/2f22fc12-62be-4f0b-a541-65f5a624d613
      

  2.   

    你直接把InstanceToWnd的代码复制
      

  3.   

    Private Function InstanceToWnd(ByVal target_pid As Long) As _    Long    Dim test_hwnd As Long    Dim test_pid As Long    Dim test_thread_id As Long     ' Get the first window handle.    test_hwnd = FindWindow(ByVal 0&, ByVal 0&)     ' Loop until we find the target or we run out    ' of windows.    Do While test_hwnd <> 0        ' See if this window has a parent. If not,        ' it is a top-level window.        If GetParent(test_hwnd) = 0 Then            ' This is a top-level window. See if            ' it has the target instance handle.            test_thread_id = _                GetWindowThreadProcessId(test_hwnd, _                test_pid)             If test_pid = target_pid Then                ' This is the target.                InstanceToWnd = test_hwnd                Exit Do            End If        End If         ' Examine the next window.        test_hwnd = GetWindow(test_hwnd, GW_HWNDNEXT)    LoopEnd Function是这些么复制粘贴了还是没有句柄啊