如题

解决方案 »

  1.   

    将当前驱动器加入到Tree中.其中 m_tree 为树.//函数功能:获取驱动器
    //@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    void CTreeViewDlg::GetLogicalDrives(HTREEITEM hParent)
    {
        size_t szAllDriveStrings = GetLogicalDriveStrings(0,NULL);
    char *pDriveStrings = new char[szAllDriveStrings + sizeof(_T(""))];
    GetLogicalDriveStrings(szAllDriveStrings,pDriveStrings);
    size_t szDriveString = strlen(pDriveStrings);
    while(szDriveString > 0)
    {
    m_tree.InsertItem(pDriveStrings,hParent);
    pDriveStrings += szDriveString + 1;
    szDriveString = strlen(pDriveStrings);
    }
    }
      

  2.   

    GetLogicalDrives
    The GetLogicalDrives function retrieves a bitmask representing the currently available disk drives. DWORD GetLogicalDrives(VOID);
    Parameters
    This function has no parameters. Return Values
    If the function succeeds, the return value is a bitmask representing the currently available disk drives. Bit position 0 (the least-significant bit) is drive A, bit position 1 is drive B, bit position 2 is drive C, and so on. If the function fails, the return value is zero. To get extended error information, call GetLastError