本帖最后由 wangxiulin 于 2012-7-19 10:41 编辑
模块:- Option Explicit
-
-
- Public Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
- Public Declare Function EnableWindow Lib "user32" (ByVal Hwnd As Long, ByVal fEnable As Long) As Long
- Dim WinHwnd&
-
-
-
- Sub Main()
- WinHwnd = FindWindow(vbNullString, "C:\windows\system32\cmd.exe")
- '寻找窗口句柄
- If VBA.Command = "" Then
- MsgBox ("命令行参数未设置")
- ' 如果参数为空 则弹出对话框
- ElseIf VBA.Command = "-a" Then
- EnableWindow WinHwnd, 0
- '如果参数为 -a 则调用API 禁止获取句柄的窗口
- ElseIf VBA.Command = "-b" Then
- EnableWindow WinHwnd, 1
- '如果参数为 -a 则调用API 取消获取句柄的窗口
- End If
- End Sub
复制代码 这个是我发的Cks.exe 的源代码。。也不算高深.. |