哪位大哥能给个列出当前所有进程的源程序…

litaoa 2003-02-09 11:22:34
谢谢了…

ma-tou@ma-tou.com
...全文
79 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
gang75 2003-02-09
  • 打赏
  • 举报
回复
' 定义一个模块(转载)
Public Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Public Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Public Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

Public Const WM_CLOSE = &H10
Public Const GW_HWNDNEXT = 2 'GW_HWNDNEXT的值为“2”,也许是移动到下个程序
Public Const GW_HWNDFIRST = 0
Public WinText As String * 256
Public Handler(200) As Long

Public Sub findrunningprogram()
Dim RenHWND As Long
Dim Count As Integer
Dim RetValue As Long
Dim WinTextLength As Long
Count = 0
Form1.List1.Clear
RenHWND = GetWindow(Form1.hwnd, GW_HWNDFIRST)
Do
RetValue = GetWindowText(RenHWND, WinText, 256)
If RetValue <> 0 Then
WinTextLength = GetWindowTextLength(RenHWND)
If Left$(WinText, WinTextLength) <> Form1.Caption And Left$(WinText, WinTextLength) <> App.Title Then
Form1.List1.AddItem RenHWND & " " & WinText '打印标识号和程序名
'If Count = 100 Then
'ReDim Preserve Handler(200)
'End If
Handler(Count) = RenHWND '定义的数组,最大200,如果大于则不行,要做判断
Count = Count + 1 '计数
End If
End If
RenHWND = GetWindow(RenHWND, GW_HWNDNEXT) 'GW_HWNDNEXT的值为“2”,也许是移动到下个程序
Loop Until RenHWND = 0
Form1.List1.ListIndex = 0
Form1.Label2.Caption = "共(" & Count & "项)"
End Sub

'*****************************************************
'窗体
Private Sub Form_Load()
'获得正在运行的程序列表
Call findrunningprogram
End Sub
xuxiongjun 2003-02-09
  • 打赏
  • 举报
回复
要给分的哦
xuxiongjun 2003-02-09
  • 打赏
  • 举报
回复
http://www.vbprobe.com/club/dispbbs.asp?boardID=30&replyID=45974&ID=10612&skin=1
进程管理器,看看就可用啦
xuxiongjun 2003-02-09
  • 打赏
  • 举报
回复
这个容易,接招
zyl910 2003-02-09
  • 打赏
  • 举报
回复
在Windows9X下用ToolHelp函数集
在WindowsNT下用EnumProcess函数
feto 2003-02-09
  • 打赏
  • 举报
回复
http://expert.csdn.net/Expert/topic/1401/1401090.xml?temp=3.669375E-02
northwolves 2003-02-09
  • 打赏
  • 举报
回复
Const TH32CS_SNAPHEAPLIST = &H1
Const TH32CS_SNAPPROCESS = &H2
Const TH32CS_SNAPTHREAD = &H4
Const TH32CS_SNAPMODULE = &H8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or TH32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Const MAX_PATH As Integer = 260
Private Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long
th32DefaultHeapID As Long
th32ModuleID As Long
cntThreads As Long
th32ParentProcessID As Long
pcPriClassBase As Long
dwFlags As Long
szExeFile As String * MAX_PATH
End Type
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Function Process32Next Lib "kernel32" (ByVal hSnapShot As Long, uProcess As PROCESSENTRY32) As Long
Private Declare Sub ExitProcess Lib "kernel32" (ByVal uExitCode As Long)
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long

Private Sub Form_Load()
Dim list1 As ListBox
Set list1 = Controls.Add("vb.listbox", "list1", Me)
list1.Visible = True
Me.Move 500, 500, 5000, 6000
Me.Caption = "程序进程"
list1.Move 500, 200, 4000, 4000
Dim hSnapShot As Long, uProcess As PROCESSENTRY32
hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0&)
uProcess.dwSize = Len(uProcess)
r = Process32First(hSnapShot, uProcess)
Do While r
list1.AddItem Left$(uProcess.szExeFile, IIf(InStr(1, uProcess.szExeFile, Chr$(0)) > 0, InStr(1, uProcess.szExeFile, Chr$(0)) - 1, 0))
'Retrieve information about the next process recorded in our system snapshot
r = Process32Next(hSnapShot, uProcess)
Loop
End Sub
catcw 2003-02-09
  • 打赏
  • 举报
回复
Option Explicit
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
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 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
Private Const SWP_NOSIZE = &H1, HWND_TOPMOST = -1, WM_CLOSE = &H10, GW_HWNDNEXT = 2, GW_HWNDFIRST = 0
Private WindowsText As String * 256, CunTemp As String, Programs(200) As Integer, ForTemp As Long

Private Sub RunningProgram()
Dim GetWinValue As Integer, Programnums As Integer
Dim GetWinTextValue As Long, WindowsTextLength As Long
Programnums = 0
List1.Clear
GetWinValue = GetWindow(Form1.hwnd, GW_HWNDFIRST)
Do
GetWinTextValue = GetWindowText(GetWinValue, WindowsText, 256)
If GetWinTextValue <> 0 Then
WindowsTextLength = GetWindowTextLength(GetWinValue)
If Left(WindowsText, WindowsTextLength) <> Form1.Caption And Left(WindowsText, WindowsTextLength) <> App.Title Then
For ForTemp = 255 To 1 Step -1
If Mid(WindowsText, ForTemp, 1) <> " " And Asc(Mid(WindowsText, ForTemp, 1)) <> 0 Then
CunTemp = Trim(Mid(WindowsText, 1, ForTemp))
Exit For
End If
Next ForTemp
For ForTemp = 0 To List1.ListCount - 1
If InStr(Trim(CunTemp), Trim(List1.List(ForTemp))) <> 0 Then GoTo 20
Next ForTemp
Form1.List1.AddItem CunTemp
20 Programs(Programnums) = GetWinValue
Programnums = Programnums + 1
End If
End If
GetWinValue = GetWindow(GetWinValue, GW_HWNDNEXT)
Loop Until GetWinValue = 0
End Sub

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧