|
-
Dec 6th, 2001, 09:06 PM
#1
Thread Starter
Hyperactive Member
Difficult? LB_GETTEXT is unreadable.
I'm using LB_GETTEXT to retrieve text from a listbox in another application, however the results are not exactly what I could have hoped for. I'm pretty sure my code here is correct, however I remember reading somewhere that I have to use ReadProcessMemory to retrieve the text, but I'm not sure. Any ideas?
Code:
Dim lCount As Long, lIndex As Long
Dim sItem As String, lLen As Long
Dim sList As String
lCount = SendMessage(hwnd, LB_GETCOUNT, 0&, ByVal 0&)
For lIndex = 0 To lCount - 1
lLen = SendMessage(hwnd, LB_GETTEXTLEN, lIndex, ByVal 0&)
sItem = Space(lLen)
Call SendMessage(hwnd, LB_GETTEXT, lIndex, ByVal sItem)
sList = sList & vbCrLf & sItem
Next
-
Dec 7th, 2001, 08:51 AM
#2
Check out the .Bas file available on this link and see if it does anything for you. I found it when doing a web search for ReadProcessMemory.
http://www.codearchive.com/vbasic/Hoax60.bas
-
Dec 8th, 2001, 03:53 AM
#3
Fanatic Member
What you can do is just alias the function and change lParam. Keep your existing declaration of SendMessage, but add another one that looks like this:
VB Code:
Declare Function SendMessageString Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, [b]ByVal lParam As String[/b]) As Long
Then in the line where you actually retrieve the text, use SendMessageString rather than your other SendMessage function, and remove the ByVal you have before your sItem param. That way, you can keep the rest of the code as you've written it with no side effect, but you don't have to do any messing around with byte arrays and worrying over unicode strings and whatnot. I tested this before posting by grabbing stuff out of mIRC nickname list, so it can get the stuff out of a listbox of a non VB (and VB) app just fine.
I'm baaaack...
VB5 Professional Edition, VC++ 6
Using a 1 gHz Thunderbird, 256 mb RAM, 40 gb HD system with Win98se
I feel special because I finally figured out how to loop midis: Post link
I'm a fanatic too 
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
|