VB枚举系统所有进程

Private Declare Function GetDesktopWindow Lib "user32" () As Long

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

Private Const GW_CHILD = 5

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

Private Const GW_HWNDNEXT = 2

Private Sub Form_click()

Dim hwnd As Long, th As Long, strname As String * 255

List1.Clear

hwnd = GetDesktopWindow()

th = GetWindow(hwnd, GW_CHILD)

n = 1

Do While th <> 0

GetWindowText th, strname, Len(strname)

th = GetWindow(th, GW_HWNDNEXT)

If Left(strname, 1) <> vbNullChar Then

List1.AddItem strname

n = n + 1

End If

Loop

End Sub

posted @ 2011-02-21 18:29  翱翔软件  阅读(1054)  评论(0)    收藏  举报

欢迎访问翱翔软件