procedure TForm1.Button9Click(Sender: TObject);var vHandle: THandle; vItemCount: Integer; vBuffer: array[0..255] of Char; vProcessId: DWORD; vProcess: THandle; vPointer: Pointer; vNumberOfBytesRead: Cardinal; I: Integer; vItem: TTVItem; vTreeItem: HTreeItem; nm: NMHDR; nTreeID:Word;begin vHandle := StrToInt(Edit7.Text); GetWindowThreadProcessId(vHandle, @vProcessId); // 获得窗体进程ID vProcess := OpenProcess(PROCESS_VM_OPERATION or PROCESS_VM_READ or PROCESS_VM_WRITE, False, vProcessId); vPointer := VirtualAllocEx(vProcess, nil, 4096, MEM_RESERVE or MEM_COMMIT, PAGE_READWRITE); Memo2.Lines.Clear; try vItemCount := TreeView_GetCount(vHandle); vTreeItem := TreeView_GetRoot(vHandle); for I := 0 to vItemCount - 1 do begin with vItem do begin mask := TVIF_TEXT; state := TVIS_SELECTED + TVIS_FOCUSED; cchTextMax := SizeOf(vBuffer); pszText := Pointer(Cardinal(vPointer) + SizeOf(vItem)); hItem := vTreeItem; end; WriteProcessMemory(vProcess, vPointer, @vItem, SizeOf(vItem), vNumberOfBytesRead); SendMessage(vHandle, TVM_GETITEM, 0, lparam(vPointer)); ReadProcessMemory(vProcess, Pointer(Cardinal(vPointer) + SizeOf(TLVItem)), @vBuffer[0], SizeOf(vBuffer), vNumberOfBytesRead); Memo2.Lines.Add(vBuffer+'vTree:'+InttoStr(Integer(vTreeItem))+'; hItem:'+inttostr(Integer(vItem.hItem))); if SameText(vBuffer, Edit8.Text) then // 通过节点文本确定 begin SendMessage(vHandle, TVM_SELECTITEM, TVGN_CARET, Integer(vTreeItem)); // 选中该节点// SendMessage(vHandle, WM_LBUTTONDOWN, MK_LBUTTON, MakeLong(50, 60));// SendMessage(vHandle, WM_LBUTTONUP, MK_LBUTTON, MakeLong(50, 60)); end; vTreeItem := TreeNodeGetNext(vHandle, vTreeItem); end; finally VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE); CloseHandle(vProcess); end;end;这段是模拟点击SysTreeView32的,因为原例子中测试的代码太多,比较乱,是找出来的代码,不是全部的,但有效的基本上都在这里了。麻烦xianjun看看,谢谢!至于有滑动条这个问题,不知道有没有办法通过当前的节点,得到在控件中的坐标。如果能的话,再通过鼠标模拟点击该坐标也许就可实现。