|
-
Feb 2nd, 2005, 12:18 PM
#1
Thread Starter
Lively Member
Someone Test really fast
Can someone tell me if it does infact get a value for the pHandle. I am having problems but I think it is because I am in a computer lab and don't have PROCESS_ALL_ACCESS. If it doesn't work at first could you replace that value with PROCESS_VM_READ. Thanks a lot!
'In button:
Private Sub Command1_Click()
Dim hwnd As Long
Dim pid As Long
Dim phandle As Long
Dim str As String
hwnd = FindWindow(vbNullString, "Calculator")
MsgBox hwnd
If (hwnd = 0) Then Exit Sub
GetWindowThreadProcessId hwnd, pid
MsgBox pid
phandle = OpenProcess(PROCESS_ALL_ACCESS, False, pid)
MsgBox phandle
If (phandle = 0) Then Exit Sub
end sub
'In .bas:
Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Declare Function GetWindowThreadProcessId Lib "user32" (ByVal hwnd As Long, lpdwProcessId As Long) As Long
Declare Function OpenProcess Lib "kernel32" (ByVal dwDesiredAccess As Long, ByVal bInheritHandle As Long, ByVal dwProcessId As Long) As Long
Declare Function WriteProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function ReadProcessMemory Lib "kernel32" (ByVal hProcess As Long, ByVal lpBaseAddress As Any, ByVal lpBuffer As Any, ByVal nSize As Long, lpNumberOfBytesWritten As Long) As Long
Declare Function CloseHandle Lib "kernel32" (ByVal hObject As Long) As Long
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 GetWindowTextLength Lib "user32" Alias "GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Public Declare Function GetNextWindow Lib "user32" Alias "GetWindow" (ByVal hwnd As Long, ByVal wFlag As Long) As Long
Public Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDest As Any, pSrc As Any, ByVal ByteLen As Long)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|