How to get the contents of TreeView controls for other processes

xiaoxiao2021-03-06  40

Extern "C" long exportitem (long thwnd, char * filestr) {tvitem TVi, * _tvi; char * _item; char item [256]; unsigned long pid; handle process; long rett = ((ctreectrl *) CWnd :: fromHandle ((hwnd) ") -> getrootItem (); if (re)) {/ * getWindowThreadProcessID Description Gets a process and thread identifier that is associated with the specified window returns a value of LONG, the thread with the window Identifier Parameter Table Parameter Type and Description LPDWProcessID Long, specify a variable, used to load an identifier hWnd long, specify window handle * / getWindowThreadProcessID ((hwnd), & PID); // with all permissions open the process process = OpenProcess (PROCESS_VM_OPERATION | PROCESS_VM_READ | PROCESS_VM_WRITE | PROCESS_QUERY_INFORMATION, FALSE, pid); // to _lvi, _item allocation process level virtual memory space _tvi = (TVITEM *) VirtualAllocEx (process, NULL, sizeof (TVITEM), MEM_COMMIT, PAGE_READWRITE); _item = (char *) VirtualAllocEx (process, NULL, 256, MEM_COMMIT, PAGE_READWRITE); tvi.cchTextMax = 256; tvi.hItem = (HTREEITEM) ret; tvi.mask = TVIF_TEXT; tvi.pszText = _item ; // Write the _LVI write process WriteProcessMemory (Process, _TVI, & TVI, SIZEOF (TVItem), NULL); // Send a message Get data :: SendMessage ((hwnd) Thwnd, TVM_GetItem, 0, (lParam) _tvi); // read data readprocessMemory from the process (Process, _Item, Item, 256, Null); // Copy Data Memcpy (FileStr, Item, 256); // Free Memory VirtualFreeEx (Process, _TVI, 0, MEM_RELEASE); VirtualFreeEx (Process, _Item, 0, MEM_RELEASE);} return ret;}

转载请注明原文地址:https://www.9cbs.com/read-67918.html

New Post(0)