如图左边是一个SysTreeView32控件,
 我想获取该控件下所有节点的句柄,并能发送消息选中单击某个指定名称节点
 求指点
 小菜鸟刚接触API不久
 在线等.....求源码
        #region API
         /* API的定义 */
         /// <summary>
         /// 本质是FindWindow,查找目标句柄
        /// </summary>
         [DllImport("user32.dll", EntryPoint = "FindWindow", SetLastError = true)]
         static extern IntPtr FindWindowByCaption(IntPtr ZeroOnly, string lpWindowName); 
最好能用c#语言写 更容易看懂

解决方案 »

  1.   

     
    Tree Control Item Information
    Home |  Overview |  SampleTree controls (CTreeCtrl) have a number of member functions that retrieve information about items in the control. The GetItem member function retrieves some or all of the data associated with an item. This data could include the item's text, state, images, count of child items, and an application-defined 32-bit data value. There is also a SetItem function that can set some or all of the data associated with an item.The GetItemState, GetItemText, GetItemData, and GetItemImage member functions retrieve individual attributes of an item. Each of these functions has a corresponding Set function for setting the attributes of an item.The GetNextItem member function retrieves the tree control item that bears the specified relationship to the current item. This function can retrieve an item's parent, the next or previous visible item, the first child item, and so on. There are also member functions to traverse the tree: GetRootItem, GetFirstVisibleItem, GetNextVisibleItem, GetPrevVisibleItem, GetChildItem, GetNextSiblingItem, GetPrevSiblingItem, GetParentItem, GetSelectedItem, and GetDropHilightItem.The GetItemRect member function retrieves the bounding rectangle for a tree control item. The GetCount and GetVisibleCount member functions retrieve a count of the items in a tree control and a count of the items that are currently visible in the tree control's window, respectively. You can ensure that a particular item is visible by calling the EnsureVisible member function.See Also   Windows Common Controls and MFC Classes
     
    Common Control Sample List
    Home |  Overview |  DetailsSee the following sample programs that illustrate common controls: CMNCTRL1
    CMNCTRL2
    CTRLTEST
    FIRE 
    Back to Control Tasks
      

  2.   

     public static bool GetTreeViewText(IntPtr AHandle) 
     {    
         uint vProcessId;
         GetWindowThreadProcessId(AHandle, out vProcessId);     IntPtr vProcess = OpenProcess(PROCESS_VM_OPERATION | PROCESS_VM_READ |
             PROCESS_VM_WRITE, false, vProcessId);
         IntPtr vPointer = VirtualAllocEx(vProcess, IntPtr.Zero, 4096,
             MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE);
         try
         {
             uint vItemCount = TreeView_GetCount(AHandle);
             IntPtr vTreeItem = GetRoot(AHandle);//根节点         vTreeItem = GetFirstChildItem(AHandle, vTreeItem);//第一个子节点
             MessageBox.Show(vItemCount.ToString());
             for (int i = 0; i < vItemCount; i++)
             {
                 byte[] vBuffer = new byte[256];
                 TVITEM[] vItem = new TVITEM[1];
                 vItem[0] = new TVITEM();
                 vItem[0].mask = TVIF_TEXT;
                 vItem[0].hItem = vTreeItem;
                 vItem[0].pszText = (IntPtr)((int)vPointer + Marshal.SizeOf(typeof(TVITEM)));
                 vItem[0].cchTextMax = vBuffer.Length;
                 uint vNumberOfBytesRead = 0;
                 WriteProcessMemory(vProcess, vPointer,
                     Marshal.UnsafeAddrOfPinnedArrayElement(vItem, 0),
                     Marshal.SizeOf(typeof(TVITEM)), ref vNumberOfBytesRead);
                 SendMessage(AHandle, TVM_GETITEMA, 0, (int)vPointer);
                 ReadProcessMemory(vProcess,
                     (IntPtr)((int)vPointer + Marshal.SizeOf(typeof(TVITEM))),
                     Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0),
                     vBuffer.Length, ref vNumberOfBytesRead);
                 MessageBox.Show(Marshal.PtrToStringAnsi(
                     Marshal.UnsafeAddrOfPinnedArrayElement(vBuffer, 0)));             vTreeItem = GetNextItem(AHandle, vTreeItem);
             }
         }
         finally
         {
             VirtualFreeEx(vProcess, vPointer, 0, MEM_RELEASE);
             CloseHandle(vProcess);
         }
         return true; 
     } 所有句柄  都有 值  但返回的 就是空的字符串