|
-
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)
-
Feb 2nd, 2005, 01:02 PM
#2
Re: Someone Test really fast
I'd be happy to except that PROCESS_ALL_ACCESS isn't defined or declared anywhere. What is that?
Also, what is PROCESS_VM_READ? Neither show up in the Constants section of the API viewer.
-
Feb 2nd, 2005, 01:07 PM
#3
Re: Someone Test really fast
Never mind. I had to Goggle them, but I got the constants definitions.
Anyway, with PROCESS_ALL_ACCESS, I got a handle, a pid and a phandle.
Do you need to have this infor posted, or are you just interested in whether I got anything other than 0?
-
Feb 2nd, 2005, 02:25 PM
#4
Thread Starter
Lively Member
Re: Someone Test really fast
Anything but 0....thanks a lot man. Damn computers in the lab won't let me do stuff to the processes I guess.
-
Feb 3rd, 2005, 09:32 AM
#5
Thread Starter
Lively Member
Re: Someone Test really fast
Any idea why this doesn't work on Windows XP?
-
Feb 3rd, 2005, 10:20 AM
#6
Re: Someone Test really fast
 Originally Posted by Lyric8
Any idea why this doesn't work on Windows XP?
I ran it on XP Pro, and it worked fine.
-
Feb 3rd, 2005, 10:52 AM
#7
Thread Starter
Lively Member
Re: Someone Test really fast
Fails on the 2 xp machines i have tried it on... UGHSSSSS no idea. Thanks though hack. appreciate it.
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
|