如何用TreeView做一个和Window一模一样的驱动器列表?
哪位大哥有这个程序给我一个也行告诉我也行,救命呀!!!
要有各种图标(驱动器、应用程序。)
算法要求点开哪个目录再进行搜索,以加快运行速度。
我知道怎么做以后再开贴给分!

解决方案 »

  1.   


    HRESULT SHGetFolderPath(
        HWND hwndOwner,
        int nFolder,
        HANDLE hToken,
        DWORD dwFlags,
        LPTSTR pszPath
    );
      

  2.   

    mfc window程序设计 中有这种例子, 完整的代码哦!!!我发给你,但是你的邮箱呢?
      

  3.   

    visual c++MFC扩展编程里面有一个很类似的例子。
    你可以参考一下,在那个基础上再改进估计就可以了。
      

  4.   

    先去网上搜索吧。
    www.codeguru.com
    www.codeproject.com
    www.mindcracker.com
    www.vckbase.com...要是还不行我看开除的一点也不冤。说得直了一点,不过公司开人不一定是公司不对,你说对不对?
      

  5.   

    你说的就是windows里面资源管理器界面吧?
    那在我上面提到的例子43:创建资源管理器界面
    中有详细介绍和代码。
      

  6.   

    LPITEMIDLIST SHBrowseForFolder(
    LPBROWSEINFO lpbi
    ); 
      

  7.   

    visual  c++MFC扩展编程这本书我没有,你把代码发给我吧
    MFC我有,但是代码实现的功能不够,thanks a lot!
      

  8.   

    // test.cpp : 定义控制台应用程序的入口点。
    //#include "stdafx.h"int _tmain(int argc, _TCHAR* argv[])
    {
    TCHAR szPath[MAX_PATH]={0};
    BROWSEINFO bi = {0};
    bi.hwndOwner = GetConsoleWindow();
    bi.lpszTitle = "Get it1";

    LPITEMIDLIST p = SHBrowseForFolder(&bi); 
    SHGetPathFromIDList( p,szPath);
        printf(szPath);
    getchar();
    return 0;
    }
    // stdafx.h : 标准系统包含文件的包含文件,
    // 或是常用但不常更改的项目特定的包含文件
    //#pragma once
    #define _WIN32_WINNT 0x0500
    #define WINVER 0x0500
    //#define WIN32_LEAN_AND_MEAN // 从 Windows 头中排除极少使用的资料
    #include <windows.h>
    #include <shlobj.h>
    #pragma comment(lib,"shell32.lib")
    #include <stdio.h>
    #include <tchar.h>// TODO: 在此处引用程序要求的附加头
      

  9.   

    我先给你个十分简单的Tree,方便你储存信息
    然后告诉你如何得到磁盘信息,使用CFileFinder
    最后关于图标,在VC的安装目录下可以找得到
    //...MyTree.h#include <vector>
    #include <iostream.h>
    using namespace std;template <class T>
    class CTreeNode
    {
    public:
      vector<int> m_ChildIndex;
      T m_Value;
      int m_Index;
      int m_ParentsIndex; // Root's m_ParentIndex=-1
    };template <class T>
    class CMyTree
    {
    protected:
      vector<CTreeNode<T>*> m_Nodes;
    public:
      int CreateRoot(T Value); // return Root's index,always it is 0,if return -1,that is there is a root already. 
      int AddChild(int ParentIndex,T Value); // return the child node's index. if return -1,that is there is no root
      int RemoveChild(int iIndex);
      T GetAt(int Index); 
      int GetCount();
      void RemoveAll();
      };template <class T>
    int CMyTree<T>::CreateRoot(T Value)
    {
    if(m_Nodes.size()>0)
    return -1;
    CTreeNode<T>* pNode=new CTreeNode<T>;
    pNode->m_Value=Value;
    pNode->m_ParentsIndex=-1;
    pNode->m_Index=0;
    m_Nodes.push_back(pNode);
    return pNode->m_Index;
    }template <class T>
    int CMyTree<T>::AddChild(int ParentIndex,T Value)
    { CTreeNode<T>* pNode=new CTreeNode<T>;
    CTreeNode<T>* pParentNode;
    if(m_Nodes.size()==0)
    {
    delete pNode;
    return -1;
    }
    if(ParentIndex<0 || ParentIndex>(int)m_Nodes.size()-1)
    {
    delete pNode;
    return -2;
    } pNode->m_Value=Value;
    pNode->m_ParentsIndex=ParentIndex;
    pNode->m_Index=(int)m_Nodes.size();

    pParentNode=m_Nodes.at(ParentIndex);
    pParentNode->m_ChildIndex.push_back(pNode->m_Index); m_Nodes.push_back(pNode);
    return pNode->m_Index;
    }template <class T>
    T CMyTree<T>::GetAt(int Index)
    {
    if(Index<0 || Index>(int)m_Nodes.size()-1)
           return NULL;
    CTreeNode<T>* pNode=m_Nodes.at(Index);
    return pNode->m_Value;
    }template <class T>
    int CMyTree<T>::GetCount()
    {
    return (int)m_Nodes.size();
    }template <class T>
    void CMyTree<T>::RemoveAll()
    {
    m_Nodes.empty();
    }template <class T>
    void CMyTree<T>::RemoveChild(int iIndex)
    {
    }看看这个程序使用的CFileFind就知道了#include <afxwin.h>
    #include <iostream>using namespace std;void Recurse(LPCTSTR pstr)
    {
       CFileFind finder;   // build a string with wildcards
       CString strWildcard(pstr);
       strWildcard += _T("\\*.*");   // start working for files
       BOOL bWorking = finder.FindFile(strWildcard);   while (bWorking)
       {
          bWorking = finder.FindNextFile();      // skip . and .. files; otherwise, we'd
          // recur infinitely!      if (finder.IsDots())
             continue;      // if it's a directory, recursively search it      if (finder.IsDirectory())
          {
             CString str = finder.GetFilePath();
             cout << (LPCTSTR) str << endl;
             Recurse(str);
          }
       }   finder.Close();
    }void main()
    {
       if (!AfxWinInit(GetModuleHandle(NULL), NULL, GetCommandLine(), 0))
          cout << "panic!" << endl;
       else
          Recurse(_T("C:"));
    }
      

  10.   

    留下你的E-mail,我发源码给你!
      

  11.   

    [email protected]
    谢谢各位大哥了!
      

  12.   

    我用的是BCB如果可以,给你一个类似的程序,另外,好象用线程的方法展开节点速度较快:P
      

  13.   

    如果没记错的话,《visual c++高级编程范例》里面有一摸一样的范例,去书店找找吧。