Board index » cppbuilder » Get External TreeView Item data

Get External TreeView Item data


2004-10-11 03:41:28 PM
cppbuilder111
hi.
I want to get external treeview item text.
my code:
DWORD pid;
HANDLE ph;
DWORD dwBytesRead, dwBytesWrite;
bool bSuccess,bWriteOK;
char szBuf[255]={0};
TVITEM ti;
TVITEM *pti;
GetWindowThreadProcessId(Sub,&pid);
ph=OpenProcess(PROCESS_ALL_ACCESS,FALSE,pid);
if(!ph)
return;
LPVOID
pszBuf=VirtualAllocEx(ph,NULL,sizeof(ti)+255,MEM_COMMIT,PAGE_READWRITE);
ZeroMemory( &ti, sizeof(ti));
ti.mask =TVIF_TEXT;
ti.hItem =TreeView_GetRoot(Sub);
DWORD(ti.pszText) =DWORD(pti)+255;
ti.cchTextMax =255;
bWriteOK=
WriteProcessMemory(ph,pszBuf,&ti,sizeof(ti),(LPDWORD)&dwBytesWrite);
TreeView_GetItem(Sub, &ti);
bSuccess=ReadProcessMemory(ph, pszBuf,&ti , sizeof(ti), &dwBytesRead);
bSuccess=ReadProcessMemory(ph, ti.pszText,szBuf , 255, &dwBytesRead);
VirtualFreeEx(ph,pszBuf,0,MEM_RELEASE);
CloseHandle(ph);
 
 

Re:Get External TreeView Item data

"Stiwin Lee" < XXXX@XXXXX.COM >wrote in message
Quote
I want to get external treeview item text.
Why are you going to all of that hassle with virtual memory? You don't need
to. Try this instead:
char szBuf[255]={0};
TVITEM ti = {0};
ti.mask = TVIF_TEXT;
ti.hItem = TreeView_GetRoot(Sub);
ti.pszText = szBuf;
ti.cchTextMax = 255;
TreeView_GetItem(Sub, &ti);
// use szBuf as needed...
Gambit
 

Re:Get External TreeView Item data

'Sub' is external program's Treeview .
I know Listview and Treeview can't transfer point in different process!
Quote

Why are you going to all of that hassle with virtual memory? You don't
need
to. Try this instead:

char szBuf[255]={0};
TVITEM ti = {0};

ti.mask = TVIF_TEXT;
ti.hItem = TreeView_GetRoot(Sub);
ti.pszText = szBuf;
ti.cchTextMax = 255;
TreeView_GetItem(Sub, &ti);
// use szBuf as needed...


Gambit


 

{smallsort}

Re:Get External TreeView Item data

Sorry.
'sub' is external program Treeview's handle .