could u let me know what is Enter hWnd of LV in Hex for the any external listview that i want obtain its data? how to get it ? Furthermore, where i will save the grabbed viewlist items?ThanksQuote:
Originally Posted by moeur
Printable View
could u let me know what is Enter hWnd of LV in Hex for the any external listview that i want obtain its data? how to get it ? Furthermore, where i will save the grabbed viewlist items?ThanksQuote:
Originally Posted by moeur
It means you don't have that file. Just change the path to any .ico file that is in your machine. Also, make sure you have the dll that is required. It should be somewhere in this thread. The zip file right before vbListView.zip. You may have to change the dll import path in the vb code to wherever you end up saving the dll.
to get handle(hWnd), you may want to look into api functions FindWindow and FindWindowEx
Quote:
Originally Posted by moeur
Question about GetLVItem.zip which is without dll
Thank u for sharing this code. I tried your project ( GetLVItem.zip) but i get the following error and nothing happens
http://i5.photobucket.com/albums/y18...od007/dam3.jpg
http://i5.photobucket.com/albums/y18...od007/dam2.jpg
could u tell me how to fix it and where the out put will will shown?Thanks
benmartin101 i still could not the the version of program that works without dll.Also i have another question how i can click and move down an external listview ? What i mean when i high light first item in an external listview i want vb goes and clicks on it and then jump to next value and goes downs the list this way. I be happy if u tell me how to achive this .Thanks and waiting for u reply.
I get errors when running the code from the free memory routinesQuote:
Originally Posted by moeur
Error releasing string buffer memory: 87 (&H57): The parameter is incorrect.
Error releasing LVITEM structure memory: 87 (&H57): The parameter is incorrect.
It does return the correct data but eventually crashes the program with the syslistview32 control.
I did not make any changes to the code in he zip file.
Thanks.
I solved the problem, or rather I found where someone else had a similar problem. I have no idea why this works so if someone knows please fill me in so I know when this has to be done. It seems that the constant defined as MEM_RELEASE = &H8000 has to be MEM_RELEASE = &H8000& with the trailing &. I don't know why the other constants seem to work fine without the trailing &. Here is the section of code changed.Quote:
Originally Posted by ed08724
Private Const MEM_COMMIT = &H1000
Private Const MEM_RESERVE = &H2000
Private Const MEM_DECOMMIT = &H4000
Private Const MEM_RELEASE = &H8000&
Two threads from 2006 and lots of posts. Is it solved or not. If not, here is how to do it.
1. Open a new standard exe project with Form1.
2. Add a listbox List1 and a commanbutton Command1 to the form.
3. Paste the code below
4. Replace "WindowName" with actual window name
5. Replace "fullpath to listview.exe" with actual string
This will start the listview exe on form load. Pushing commandbutton will retrieve all listview items text.
Hope this will solve this problem.
Code:Option Explicit
Private Const LVIF_TEXT As Long = &H1
Private Const LVM_FIRST As Long = &H1000
Private Const LVM_GETITEM As Long = (LVM_FIRST + 5)
Private Const LVM_SETITEM As Long = (LVM_FIRST + 6)
Private Const LVM_GETITEMCOUNT As Long = (LVM_FIRST + 4)
Private Const MEM_COMMIT As Long = &H1000
Private Const PAGE_READWRITE As Long = &H4
Private Const STANDARD_RIGHTS_REQUIRED As Long = &HF0000
Private Const SYNCHRONIZE As Long = &H100000
Private Const PROCESS_ALL_ACCESS As Long = (STANDARD_RIGHTS_REQUIRED Or SYNCHRONIZE Or &HFFF)
Private Const MEM_RELEASE As Long = &H8000
Private Type LVITEM
mask As Long
iItem As Long
iSubItem As Long
state As Long
stateMask As Long
pszText As Long 'Notice not string but long
cchTextMax As Long
iImage As Long
lParam As Long
iIndent As Long
End Type
Private Declare Function OpenProcess Lib "kernel32.dll" ( _
ByVal dwDesiredAccess As Long, _
ByVal bInheritHandle As Long, _
ByVal dwProcessId As Long) As Long
Private Declare Function WriteProcessMemory Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByRef lpBaseAddress As Any, _
ByRef lpBuffer As Any, _
ByVal nSize As Long, _
ByRef lpNumberOfBytesWritten As Long) As Long
Private Declare Function ReadProcessMemory Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByRef lpBaseAddress As Any, _
ByRef lpBuffer As Any, _
ByVal nSize As Long, _
ByRef lpNumberOfBytesWritten As Long) As Long
Private Declare Function GetWindowThreadProcessId Lib "user32.dll" ( _
ByVal hwnd As Long, _
ByRef lpdwProcessId As Long) As Long
Private Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" ( _
ByVal lpClassName As Long, _
ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" ( _
ByVal hwndParent As Long, _
ByVal hwndChildAfter As Long, _
ByVal lpszClass As String, _
ByVal lpszWindow As Long) As Long
Private Declare Function SendMessage Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hwnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long
Private Declare Function VirtualAllocEx Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal flAllocationType As Long, _
ByVal flProtect As Long) As Long
Private Declare Function VirtualFreeEx Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByVal lpAddress As Long, _
ByVal dwSize As Long, _
ByVal dwFreeType As Long) As Long
Private Declare Function CloseHandle Lib "kernel32.dll" ( _
ByVal hObject As Long) As Long
Private Declare Function TerminateProcess Lib "kernel32.dll" ( _
ByVal hProcess As Long, _
ByVal uExitCode As Long) As Long
Dim hProcess As Long
Private Sub Command1_Click()
Dim hndl As Long
Dim hListView As Long
Dim lpdwProcessId As Long
Dim pMem As Long
Dim lvi As LVITEM
Dim lpNumberOfBytesWritten As Long
Dim i As Long
Dim cItems As Long
Dim txt As String
Dim pTxt As Long
'Get the handle of listview control
hndl = FindWindow(0, "WindowName")
hListView = FindWindowEx(hndl, 0, "SysListView32", 0)
'Retrieve a handle of the listview control process
GetWindowThreadProcessId hListView, lpdwProcessId
hProcess = OpenProcess(PROCESS_ALL_ACCESS, False, lpdwProcessId)
'Allocate memory in listview process memory space for the LVITEM structure and listitem text
pMem = VirtualAllocEx(hProcess, 0, Len(lvi), MEM_COMMIT, PAGE_READWRITE)
pTxt = VirtualAllocEx(hProcess, 0, 256, MEM_COMMIT, PAGE_READWRITE)
'Retrieve number of listview items
cItems = SendMessage(hListView, LVM_GETITEMCOUNT, 0, 0)
'Fill a LVITEM structure with values
lvi.mask = LVIF_TEXT
lvi.cchTextMax = 256
lvi.pszText = pTxt 'This is a pointer to the address where item text will be hold
'Allocate space for a string
txt = Space(256)
For i = 0 To cItems - 1
'Add item index to structure
lvi.iItem = i
'Transfer the structure to allocated memory in listview memory space
WriteProcessMemory hProcess, ByVal pMem, lvi, Len(lvi), lpNumberOfBytesWritten
'Send message to get listview item [i]. Result hold in LVITEM strucktur at address pMem
SendMessage hListView, LVM_GETITEM, 0, ByVal pMem
'Transfer the item text from allocated memory at pTxt to txt space in this app process memory
ReadProcessMemory hProcess, ByVal pTxt, ByVal txt, 256, lpNumberOfBytesWritten
List1.AddItem txt
Next i
'Free allocated memory
VirtualFreeEx hProcess, pMem, Len(lvi), MEM_RELEASE
VirtualFreeEx hProcess, pTxt, 256, MEM_RELEASE
End Sub
Private Sub Form_Load()
Shell "fullpath to listview.exe"
End Sub
Private Sub Form_Terminate()
TerminateProcess hProcess, 0
CloseHandle hProcess
End Sub
It doesn't work on mine or at least not for long because of the memory leak which I described above on how to fix. I don't know why I have to do this or why others don't seem to have the same problem. I would be interested to know if you debug.print the results from VirtualFreeEx hProcess, pMem, Len(lvi), MEM_RELEASE
to see if it runs w/o error.
like:
debug.print VirtualFreeEx(hProcess, pMem, Len(lvi), MEM_RELEASE)
debug.print VirtualFreeEx(hProcess, pTxt, 256, MEM_RELEASE)
Quote:
Originally Posted by minor28
You are right I was too quick writing. I did commit the memory space and thus must decommit it.
This is how it is done
Code:VirtualFreeEx hProcess, pMem, 0, MEM_DECOMMIT
VirtualFreeEx hProcess, pTxt, 0, MEM_DECOMMIT
It seems that on Win98/ME &H8000 returns 32768 but on NT/XP it returns -32768 but &H8000& returns 32768 on both. So the answer is to use the trailing & on any numbers greater than &H7FFF. (Keywords syslistview32 memory leakage memory creep vb6 vb MEM_RELEASE)Quote:
Originally Posted by ed08724
Hi everyone,
I'm sort of new here, although i've been a post reader for a while i've not done any posting my self.
I'm wondering if I may be able to adapt moeurs code to stop an external app from closing without using a seperate dll.
Maybe I'm in the wrong place and this code won't work for me but maybe someone can help me out?
I have posted here explaining what I need to do, and source code of my subclass control and test app (which is a bit untidy but works when referenced in a vb app :)):
http://www.vbforums.com/showthread.p...07#post3193507
PLEASE HELP ME :confused:
If you can find the window message that hits when an application is closing then you can stop that. But i don't know the name of this message.
thanks sapator, I've built a small activeX dll which can get the handle under mouse, get parent and subclass to stop closing. When I reference my dll in another vb6 app it works but when I try to subclass an external app (none vb) it doesn't.Quote:
Originally Posted by sapator
My dll can also be used to monitor system messages (a bit like spy) because the form I'm trying to subclass closes when it loses focus which makes it impossible to watch with spy.
My first post has the link to my thread which explains a what I need to do and has the source and test app for my dll.
The messages i'm trying to stop are WM_CLOSE and WM_SYSCOMMAND with param SC_CLOSE for now.
I don't want to clutter this thread with too much non-related content so if you can help me please can you post in my thread:)