代码如下
Option Explicit
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 IsWindowEnabled Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EnableWindow Lib "user32.dll" (ByVal hwnd As Long, ByVal fEnable As Long) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Const GW_CHILD = 5
Private Const GW_HWNDNEXT = 2
Private Const WM_ENABLE As Long = &HAPrivate Sub Command1_Click()
Dim tWnd As Long
Dim bWnd As Long
Dim lpClassName As String
Dim RetVal As Long
Dim i As Integer
Dim mName As String
tWnd = FindWindow(vbNullString, "系统属性")  '该为你想要找的哪个窗口的标题
bWnd = GetWindow(tWnd, GW_CHILD)
Do
If IsWindowEnabled(bWnd) = 0 Then
List1.AddItem bWnd
End If
bWnd = GetWindow(bWnd, GW_HWNDNEXT)
Loop While bWnd <> 0
End Sub
Private Sub List1_Click()
EnableWindow List1.List(List1.ListIndex), True
End Sub
比如,右键我的电脑(xp),选择属性,然后选择远程,其中有两个按钮的enable为false ,用上面的程序可以使的应用按钮变为可用,而高级按钮却没有找到相应的句柄,也就不可以改变它的enable属性。
而用枚举子窗口可以改变其enable属性。