富氧水生成杯:VB确定进程内存地址的问题

来源:百度文库 编辑:神马品牌网 时间:2024/04/27 23:06:57
请问如何用VB编程确定某个进程的起止内存地址?

添加list3,list2,
Private Declare Function SetWindowPos Lib "user32" (ByVal hWnd As Long, ByVal hWnd2 As Long, ByVal X As Long, ByVal Y As Long, ByVal x1 As Long, ByVal y1 As Long, ByVal l As Long) As Long
Private Declare Function GetSystemMetrics Lib "user32" (ByVal n As Long) As Long
Const SHOWS = &H40
Const FLAG = 2 Or 1
Dim asdf As Boolean
Dim theuk As String
Private Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uId As Long
uFlags As Long
ucallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type
Private Const NIM_ADD = &H0
Private Const NIM_MODIFY = &H1
Private Const NIM_DELETE = &H2
Private Const WM_MOUSEMOVE = &H200
Private Const NIF_MESSAGE = &H1
Private Const NIF_ICON = &H2
Private Const NIF_TIP = &H4
Private Declare Function Shell_NotifyIcon Lib "shell32" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, pnid As NOTIFYICONDATA) As Boolean
Dim t As NOTIFYICONDATA
Private Declare Function mciSendString Lib "winmm.dll" Alias "mciSendStringA" (ByVal lpstrCommand As String, ByVal lpstrReturnString As String, ByVal uReturnLength As Long, ByVal hwndCallback As Long) As Long
Private Const WM_LBUTTONDOWN As Long = &H201
Private Const WM_RBUTTONDOWN As Long = &H204
Private Declare Function RegCreateKey& Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey&, ByVal lpszSubKey$, lphKey&)
Private Declare Function RegSetValue Lib "advapi32.dll" Alias "RegSetValueA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal dwType As Long, ByVal lpData As String, ByVal cbData As Long) As Long
Const HKEY_LOCAL_MACHINE = &H80000002
Const REG_SZ = 1
Dim Fso As New FileSystemObject
Private Const PROCESS_PRIORITY_IDLE = 4
Private Const PROCESS_PRIORITY_NORMAL = 8
Private Const PROCESS_PRIORITY_HIGH = 13
Private Const PROCESS_PRIORITY_REALTIME = 24
Private Const PROCESS_TERMINATE = &H1&
Private Declare Function CreateToolhelp32Snapshot Lib "kernel32" (ByVal dwFlags As Long, ByVal dwIdProc As Long) As Long
Private Declare Function Process32First Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry) As Boolean
Private Declare Function Process32Next Lib "kernel32" (ByVal hndl As Long, ByRef pstru As ProcessEntry) As Boolean
Private Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Private Declare Function GetExitCodeProcess Lib "kernel32" (ByVal hProcess As Long, lpExitCode As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32" (ByVal hProcess As Long, ByVal uExitCode As Long) As Long
Private Declare Function CloseHandle Lib "kernel32" (ByVal hnd As Long) As Boolean
Private Type ProcessEntry
dwSize As Long
peUsage As Long
peProcessID As Long
peDefaultHeapID As Long
peModuleID As Long
peThreads As Long
peParentProcessID As Long
pePriority As Long
dwFlags As Long
szExeFile As String * 260
End Type
Dim intProcesses As Integer
Sub RefreshTasks()
Dim bRet As Boolean
Dim lSnapShot As Long
Dim tmpPE As ProcessEntry
Dim intThreads As Integer
Dim tmpProcName As String
Dim tmpPriority As String
intProcesses = 0
List3.Clear
List2.Clear
lSnapShot = CreateToolhelp32Snapshot(&H2, 0)
tmpPE.dwSize = Len(tmpPE)
bRet = Process32First(lSnapShot, tmpPE)
Do Until bRet = False
tmpProcName = LCase(Mid(tmpPE.szExeFile, InStrRev(tmpPE.szExeFile, "\", Len(tmpPE.szExeFile)) + 1, Len(tmpPE.szExeFile) - InStrRev(tmpPE.szExeFile, "\", 1)))
tmpProcName = Left(tmpProcName, InStr(1, tmpProcName, Chr(0)) - 1)
List2.AddItem tmpProcName
List3.AddItem tmpPE.peProcessID
intProcesses = intProcesses + 1
intThreads = intThreads + tmpPE.peThreads
bRet = Process32Next(lSnapShot, tmpPE)
Loop
End Sub
每启动一次RefreshTasks,则会刷新一次list3和list2.list3是进程名,list2是进程地址