发信人: whc()
整理人: winsy(2003-03-05 15:24:58), 站内信件
|
Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlag s As Long, ByVal th32ProcessID As Long) As Long
Const TH32CS_SNAPHEAPLIST = 1
Const TH32CS_SNAPPROCESS = 2
Const TH32CS_SNAPTHREAD = 4
Const TH32CS_SNAPMODULE = 8
Const TH32CS_SNAPALL = (TH32CS_SNAPHEAPLIST Or TH32CS_SNAPPROCESS Or T H32CS_SNAPTHREAD Or TH32CS_SNAPMODULE)
Const TH32CS_INHERIT = &H80000000
Type PROCESSENTRY32
dwSize As Long
cntUsage As Long
th32ProcessID As Long '; // this process
th32DefaultHeapID As Long
th32ModuleID As Long '; // associated exe
cntThreads As Long
th32ParentProcessID As Long '; // this process's parent process
pcPriClassBase As Long '; // Base priority of process's thread s
dwFlags As Long
szExeFile As String * 500 '[MAX_PATH]; // Path
End Type
Declare Function Process32First Lib "kernel32" (ByVal hSnapshot As Lon g, lppe As PROCESSENTRY32) As Boolean
Declare Function Process32Next Lib "kernel32" (ByVal hSnapshot As Long , lppe As PROCESSENTRY32) As Boolean
______________________________________
Dim hPS As Long, pe32 As PROCESSENTRY32
Dim buffer As String * 255, loaded As Boolean
loaded = False
hPS = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0)
If hPS = -1 Then End
pe32.dwSize = Len(pe32)
If Process32First(hPS, pe32) Then
While Process32Next(hPS, pe32)
' nullstring(pe32.szExeFile) 为WIN程序的文件名
End If
Wend
End If
_________________________________________
Function nullstring(s As String) As String
Dim lo As Integer
For lo = 1 To Len(s)
If Mid$(s, lo, 1) = Chr$(0) Then Exit For
Next
If lo > 1 Then
nullstring = Left$(s, lo - 1)
End If
End Function
-- ※ 来源:.月光软件站 http://www.moon-soft.com.[FROM: 202.96.26.132]
|
|