资源简介
读取SysListView32用的c++源码
代码片段和文件信息
#include “StdAfx.h“
#include “Reader_SysListView32.h“
#include “DrawLib.h“
Reader_SysListView32::Reader_SysListView32(void)
{
}
Reader_SysListView32::~Reader_SysListView32(void)
{
}
void Reader_SysListView32::Reset(void)
{
ClearData();
ClearHeader();
}
void Reader_SysListView32::ClearData(void)
{
row.clear();
}
void Reader_SysListView32::ClearHeader(void)
{
header.clear();
}
BOOL Reader_SysListView32::Read(HWND hwnd)
{
Reset();
int cols=GetCols(hwnd);
if(!cols)return 0;
int rows=GetRows(hwnd);
DWORD pid=GetWindowPid(hwnd);
if(!pid)return 0;
HANDLE hp=ProcessOpen(pid);
if(!hp)return 0;
DWORD nMemSize=64*1024;
DWORD rmAddr=ProcessAlloc(hpnMemSize);
if(!rmAddr)return 0;
cols=ReadHeader(hphwndrmAddrnMemSize);
if(rows)
{
ReadTable(hphwndrmAddrnMemSizecols);
}
ProcessFree(hprmAddrnMemSize);
ProcessClose(hp);
return 1;
}
int Reader_SysListView32::ReadHeader(HANDLE hProcessHWND hwnd DWORD nRemoteBufferAddress DWORD nBufferSize)
{
//CString sClass=GetWindowClass(hwnd); //有些窗口类不是“SysListView32“也能被读取,如exescope里的表格,可能是它的派生类
int nCols=GetCols(hwnd);
if(!nCols)return 0;
HWND hHeader=GetHeaderWnd(hwnd);
DWORD nbaseSize=128; //比sizeof(HDITEM)大一点
DWORD nTextAddr=nRemoteBufferAddress+nbaseSize;
DWORD nBuffLen=(nBufferSize-nbaseSize)/sizeof(TCHAR);
if(nBufferSize<=nbaseSize+2)return 0;
TCHAR *pText=(TCHAR*)new char[nBufferSize];
HDITEM hi={0};
for(int i=0;i {
hi.cchTextMax=nBuffLen;
hi.pszText=(TCHAR*)nTextAddr;
hi.mask=HDI_TEXT;
if(!ProcessWrite(hProcessnRemoteBufferAddressnbaseSize&hi))break;
if(::SendMessage(hHeaderHDM_GETITEMinRemoteBufferAddress))
{
ProcessReadText(hProcessnTextAddrpTextnBufferSize/sizeof(TCHAR));
header.push_back(pText);
}
}
delete pText;
return nCols;
}
int Reader_SysListView32::ReadTable(HANDLE hProcessHWND hwnd DWORD nRemoteBufferAddress DWORD nBufferSizeint nCols)
{
//LVM_GETCOLUMN也能检测列数量,可以从0列开始一个个测试,但是如果不是报表风格则可能错误。一旦是报表风格则一定会有头控件所以依然使用头控件返回的列数nCols
int nRows=GetRows(hwnd);
if(!nRows)return 0;
DWORD nbaseSize=128; //比sizeof(LVITEM)大一点
DWORD nTextAddr=nRemoteBufferAddress+nbaseSize;
DWORD nBuffLen=(nBufferSize-nbaseSize)/sizeof(TCHAR);
if(nBufferSize<=nbaseSize+2)return 0;
TCHAR *pText=(TCHAR*)new char[nBufferSize];
LVITEM li={0};
Row BlankRow;
for(int r=0;r {
Reader_SysListView32::row.push_back(BlankRow);
Row&row=Reader_SysListView32::row[Reader_SysListView32::row.size()-1];
for(int c=0;c {
li.cchTextMax=nBuffLen;
li.pszText=(LPTSTR)nTextAddr;
li.mask=LVIF_TEXT;
li.iItem=r;
li.iSubItem=c;
if(!ProcessWrite(hProcessnRemoteBufferAddressnbaseSize&li))break;
if(::SendMessage(hwndLVM_GETITEM0nRemoteBufferAddress))
{
ProcessReadText(hProcessnTextAddrpTextnBufferSize/sizeof(TCHAR));
row.push_back(pText);
}
}
}
delete pText;
retu
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 4798 2012-05-16 16:22 Reader_SysListView32.cpp
文件 649 2012-05-15 15:11 Reader_SysListView32.h
文件 1153 2012-05-16 16:19 ProcessOperator.h
文件 4040 2012-05-16 16:15 ProcessOperator.hpp
文件 118 2013-08-03 10:40 说明.txt
----------- --------- ---------- ----- ----
10758 5
评论
共有 条评论