1,486
社区成员
发帖
与我相关
我的任务
分享
Public Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As Long
Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long
Public Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)
Public Declare Function IsWindowVisible Lib "user32" (ByVal hwnd As Long) As Long
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Const SWP_HIDEWINDOW = &H80
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
Public Const WM_CLOSE = &H10
Public Function EnumChildProc0(ByVal hwnd As Long, ByVal lParam As Long) As Long
Dim strlong As Long
Dim tempstr As String
Dim strCap As String
Dim capLong As Long
Dim rtn As Long
Dim result As Long
tempstr = Space(255)
strlong = Len(tempstr)
strCap = Space(255)
capLong = Len(strCap)
rtn = GetClassName(hwnd, tempstr, strlong)
rtn = GetWindowText(hwnd, strCap, capLong)
If Trim(strCap) <> "" Then
MsgBox Trim(strCap)
MsgBox hwnd
End If
If (InStr(1, Trim(strCap), "穝郎", vbTextCompare) > 0) Then
hwnd = FindWindow(vbNullString, "穝郎")
If hwnd = 0 Then
'MsgBox "ゼт怠"
Else
result = PostMessage(hwnd, WM_CLOSE, 0&, 0&)
If result = 0 Then
'MsgBox "闽超怠ア毖"
Else
'MsgBox "OK"
End If
End If
end if
End sub
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Const WM_CLOSE = &H10
Dim Handle As Long
Private Sub Form_Load()
Timer1.Interval = 200
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Handle = FindWindow(vbNullString, "另存为")
If Handle <> 0 Then
SendMessage Handle, WM_CLOSE, 0, 0
End If
End Sub
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Private Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Const MF_DISABLED = &H2&
Private Const MF_ENABLED = &H0&
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Dim Handle As Long
Dim hMenu As Long, nCount As Long
Private Sub Command1_Click()
Shell "calc.exe", 1
Handle = FindWindow(vbNullString, "计算器")
hMenu = GetSystemMenu(Handle, 0)
nCount = GetMenuItemCount(hMenu)
End Sub
Private Sub Command2_Click()
Call EnableMenuItem(hMenu, nCount - 1, MF_DISABLED Or MF_BYPOSITION)
DrawMenuBar Handle
End Sub