-
April 26th, 2010, 12:10 AM
#1
what is wrong in this code
Code:
Public Function SysListView32ToCSV(ByVal hListView As Long, ByVal DestPath As String, ByVal Delimiter As String) As Boolean
On Error GoTo ErrHandler
Dim ListCount As Long, ColumnCount As Long, HeaderhWnd As Long
Dim ProcessID As Long, ProcessHandle As Long
Dim MemAddr1 As Long, MemAddr2 As Long
Dim i As Long, j As Long, lRtn As Long
Dim sLine As String, sText As String, ItemText As String
Dim ListViewItem As LVITEM
Dim HeaderItem As HDITEM
Dim aText(260) As Byte
Dim FF As Integer
ListCount = SendMessage(hListView, LVM_GETITEMCOUNT, 0, ByVal 0&)
Debug.Print ListCount
HeaderhWnd = SendMessage(hListView, LVM_GETHEADER, 0, ByVal 0&)
ColumnCount = SendMessage(HeaderhWnd, HDM_GETITEMCOUNT, 0, ByVal 0&)
If Dir(DestPath) <> "" Then Kill DestPath
GetWindowThreadProcessId hListView, ProcessID
If ProcessID = 0 Then Exit Function
ProcessHandle = OpenIPCProcess(ProcessID)
If ProcessHandle Then
FF = FreeFile
Open DestPath For Append As #FF
MemAddr1 = CreateIPCMemory(36, ProcessHandle)
MemAddr2 = CreateIPCMemory(261, ProcessHandle)
If Not (MemAddr1 = 0& Or MemAddr2 = 0&) Then
With HeaderItem
.cchTextMax = 260&
.mask = HDI_TEXT
.pszText = MemAddr2
End With
For i = 0 To ColumnCount - 1
WriteIPCMemory ProcessHandle, MemAddr1, VarPtr(HeaderItem), 36&
lRtn = SendMessage(HeaderhWnd, HDM_GETITEMA, i, ByVal MemAddr1)
If lRtn Then
ReadIPCMemory ProcessHandle, MemAddr2, VarPtr(aText(0)), 260&
ItemText = StrConv(aText, vbUnicode)
ItemText = Left$(ItemText, InStr(ItemText, vbNullChar) - 1)
sLine = sLine & ItemText & IIf(j < ColumnCount - 1, Delimiter, vbNullString)
Debug.Print sLine
End If
Next
Print #FF, sLine
' Release virtual memory
DestroyIPCMemory ProcessHandle, MemAddr1
End If
' Create virtual memory
MemAddr1 = CreateIPCMemory(40, ProcessHandle)
If Not (MemAddr1 = 0& Or MemAddr2 = 0&) Then
With ListViewItem
.cchTextMax = 260&
.mask = LVIF_TEXT
.pszText = MemAddr2
End With
For i = 0 To ListCount - 1
sLine = vbNullString
For j = 0 To ColumnCount - 1
ListViewItem.iSubItem = j
WriteIPCMemory ProcessHandle, MemAddr1, VarPtr(ListViewItem), 40&
lRtn = SendMessage(hListView, LVM_GETITEMTEXTA, i, ByVal MemAddr1)
If lRtn > 0& Then
ReadIPCMemory ProcessHandle, MemAddr2, VarPtr(aText(0)), 260&
sLine = sLine & Left$(StrConv(aText, vbUnicode), lRtn) & IIf(j < ColumnCount - 1, Delimiter, vbNullString)
End If
Next
Print #FF, sLine
Next
' Release virtual memory
DestroyIPCMemory ProcessHandle, MemAddr1
End If
Close #FF
' Release virtual memory
If MemAddr2 <> 0& Then DestroyIPCMemory ProcessHandle, MemAddr2
CLoseIPCProcess ProcessHandle
SysListView32ToCSV = True
End If
Exit Function
ErrHandler:
End Function
this code returns the syslistview32 column headers to the output file but is not able to return the syslistview32 items
can any expert help me on this by checking where it is wrong
-
April 26th, 2010, 01:22 AM
#2
Re: what is wrong in this code
OK, if you give us more of a background as to what this code actually does, you might get more decent help......
-
April 26th, 2010, 01:35 AM
#3
Re: what is wrong in this code
Originally Posted by HanneSThEGreaT
OK, if you give us more of a background as to what this code actually does, you might get more decent help......
code is supposed to fetch data from a third party application's syslistview32.the code is able to get the headers but not the text
below is the screenshot of the app
http://img682.yfrog.com/img682/7311/screenshotry.jpg
its able to fetch Exchange,Instrument name...... the headers but not able to fetch the text in the red box. the red box is just used to highlight the text i want to fetch
this is entire code
http://www.4shared.com/file/MKtgaAmC/desktop.html
-
April 26th, 2010, 06:11 AM
#4
Re: what is wrong in this code
I promise there is nothing wrong with your SysListView32ToCSV procedure!
I had sent the testing version back to you, which contained a ListView named lvWof and a testing routine which read out the lvWof texts completetly right.
This procedure works, is well done and seems not to be the reason for the problem you have.
If you have some more patience, I might give it another go tonight.
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
|