各位大神,我想让窗口嵌入Win7桌面,枚举所有WorkerW找到SHELLDLL_DefView,把父窗口设置为SHELLDLL_DefView
vb.net2015代码如下:
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As IntPtr
Private Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As IntPtr
Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hwndParent As IntPtr, ByVal hwndChildAfter As IntPtr, ByVal lpszClass As String, ByVal lpszWindow As String) As IntPtr
Private Declare Function EnumWindows Lib "user32" Alias "EnumWindows" (ByVal MyCallBack As EnumWindowsProc, ByVal lParam As Integer) As Integer
Private Delegate Function EnumWindowsProc(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
Private Function EnumWindowsProcCallBack(ByVal hwnd As IntPtr, ByVal lParam As Integer) As Boolean
If hwnd = FindWindow("WorkerW", vbNullString) Then
If hwnd = FindWindowEx(hwnd, vbNull, "SHELLDLL_DefView", vbNullString) Then
SetParent(Me.Handle, hwnd)
EnumWindowsProcCallBack = False
Else
EnumWindowsProcCallBack = True
End If
Else
EnumWindowsProcCallBack = True
End If
End Function
Dim MyCallBack As EnumWindowsProc
MyCallBack = New EnumWindowsProc(AddressOf EnumWindowsProcCallBack)
EnumWindows(MyCallBack, 0)
可是最终用Spy++查看并没有效果是怎么回事?跪求大神指点!多谢!