I'm trying to capture data from a SysListView32 class (according to Spy++) from another application. Sending a LVM_GETITEMCOUNT message to this handle always returns the correct number of items. There is a child window which is SysHeader32 which presumably contains header titles.
When I try to send a LVM_GETITEMTEXT message to the target application, it crashes. The relevant code for this message is below:
LPTSTR lpText;
LVITEM* lvItem;
lvItem = new LVITEM;
lvItem->iSubItem = 0;
lvItem->cchTextMax = 255;
lvItem->pszText = lpText;
//SysListViewHandle is the HWND to the SysListView32 'content' window
SendMessage(SysListViewHandle, LVM_GETITEMTEXT, 1, (long)lvItem);
Each 'cell' in the list contains text no more than 50 characters, so the max text size should be fine.
The list structure which I wish to get the data from has 16 columns and a variable number of entries, more than 5, so the wParam should be fine. The styles this list use are WS_CHILDWINDOW, WS_VISIBLE, WS_TABSTOP, WS_HSCROLL, LVS_REPORT with extended styles of WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR, WS_EX_NOPARENTNOTIFY, WS_EX_CLIENTEDGE, LVS_GRIDLINES and LVS_FULLROWSELECT.
UISpy is able to probe this list and find the actual data within so I presumed it would be a walk in the park to get using messages, but this has proved not the case =/ any assistance would be greatly appreciated.
EDIT: Worth mentioning the error log on crashing is: Unhandled exception at 0x77582b87 in applicationname.exe: 0xC0000005: Access violation writing location 0x01bc48b0. Call stack location comctl32.dll Disassembly: 77582B87 mov dword ptr [esi],1