⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 module1.bas

📁 很好的教程原代码!
💻 BAS
字号:
Attribute VB_Name = "Module1"
Option Explicit

Type wndClass
    style As Long
    lpfnwndproc As Long
    cbClsextra As Long
    cbWndExtra2 As Long
    hInstance As Long
    hIcon As Long
    hCursor As Long
    hbrBackground As Long
    lpszMenuName As String
    lpszClassName As String
End Type

Type RECT
        Left As Long
        Top As Long
        Right As Long
        Bottom As Long
End Type

'API 声明
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

Declare Function GetDesktopWindow Lib "user32" () As Long

Declare Function GetWindow Lib "user32" _
    (ByVal hwnd As Long, ByVal wCmd As Long) As Long

Declare Function GetWindowText Lib "user32" Alias _
    "GetWindowTextA" (ByVal hwnd As Long, _
    ByVal lpString As String, ByVal cch As Long) _
    As Long

'常量
Public Const WM_ACTIVATE = &H6
Public Const SWP_NOMOVE = &H2
Public Const SWP_NOSIZE = &H1
Public Const HWND_TOPMOST = -1
Public Const GW_CHILD = 5
Public Const GW_HWNDNEXT = 2

'获取所有进程的函数
Public Function GetOpenWindowNames() As Long
    Dim lngDeskTopHandle As Long    'Used to hold the value of the Desktop handle.
    Dim lngHand As Long             'Used to hold each windows handle as it loops.
    Dim strName As String * 255     'Fixed length string passed to GetWindowText API call.
    Dim lngWindowCount As Long      'Counter used to return the numberof open windows in the system.
    
    '得到desktop的句柄
    lngDeskTopHandle = GetDesktopWindow()
    
    '得到desktop的第一个子窗体
    lngHand = GetWindow(lngDeskTopHandle, GW_CHILD)
    '窗体数目
    lngWindowCount = 1
    '循环所有的窗体
    Do While lngHand <> 0
         '获得窗体的Name
         GetWindowText lngHand, strName, Len(strName)
         
         'Get the sibling of the current window.
         lngHand = GetWindow(lngHand, GW_HWNDNEXT)
         
         '确认窗体有标题
         If Left$(strName, 1) <> vbNullChar Then
              Main.lstOpenWindows.AddItem Left$(strName, InStr(1, strName, vbNullChar))
              lngWindowCount = lngWindowCount + 1
         End If
    Loop
  
    '返回窗体的数目
    GetOpenWindowNames = lngWindowCount
End Function


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -