调用系统通用对话框打开文件/文件夹

// 文件
void SelectFile(std::string& path)  
{  
    OPENFILENAME open_file_name;    // 公共对话框结构。       
    char file[MAX_PATH];            // 保存获取文件名称的缓冲区。                 
                                    // 初始化选择文件对话框。       
    ZeroMemory(&open_file_name, sizeof(OPENFILENAME));  
    open_file_name.lStructSize = sizeof(OPENFILENAME);  
    open_file_name.hwndOwner = 0;  
    open_file_name.lpstrFile = file;  
    open_file_name.lpstrFile[0] = '\0';  
    open_file_name.nMaxFile = sizeof(file);  
    open_file_name.lpstrFilter = "avi文件(*.*)\0*.avi\0mp4(*.mp4)\0*.mp4\0\0";  
    open_file_name.nFilterIndex = 1;  
    open_file_name.lpstrFileTitle = 0;  
    open_file_name.nMaxFileTitle = 0;  
    open_file_name.lpstrInitialDir = 0;  
    open_file_name.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;  
    //ofn.lpTemplateName =  MAKEINTRESOURCE(ID_TEMP_DIALOG);  

    // 显示打开选择文件对话框。  
    if (GetOpenFileName(&open_file_name))  
    {  
        path = file;  
    }  
}  

// 文件夹  
void SelectDir(std::string& path)  
{  
    char path_buff[MAX_PATH];  
    ZeroMemory(path_buff, MAX_PATH);  

    BROWSEINFO browse_info;  
    browse_info.hwndOwner = 0;  
    browse_info.pidlRoot = 0;  
    browse_info.pszDisplayName = 0;  
    browse_info.lpszTitle = "请选择文件夹";  
    browse_info.ulFlags = BIF_RETURNONLYFSDIRS | BIF_STATUSTEXT;  
    browse_info.lpfn = 0;  
    browse_info.lParam = 0;  
    browse_info.iImage = 0;  

    LPITEMIDLIST item_id_list = SHBrowseForFolder(&browse_info);  
    if (item_id_list == 0)  
    {  
        return;  
    }  

    if (SHGetPathFromIDList(item_id_list, path_buff))  
    {  
        path = path_buff;  
    }  
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
/* * 基于双向链表实现双端队列结构 */ package dsa; public class Deque_DLNode implements Deque { protected DLNode header;//指向头节点(哨兵) protected DLNode trailer;//指向尾节点(哨兵) protected int size;//队列中元素的数目 //构造函数 public Deque_DLNode() { header = new DLNode(); trailer = new DLNode(); header.setNext(trailer); trailer.setPrev(header); size = 0; } //返回队列中元素数目 public int getSize() { return size; } //判断队列是否为空 public boolean isEmpty() { return (0 == size) ? true : false; } //取首元素(但不删除) public Object first() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); return header.getNext().getElem(); } //取末元素(但不删除) public Object last() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); return trailer.getPrev().getElem(); } //在队列前端插入新节点 public void insertFirst(Object obj) { DLNode second = header.getNext(); DLNode first = new DLNode(obj, header, second); second.setPrev(first); header.setNext(first); size++; } //在队列后端插入新节点 public void insertLast(Object obj) { DLNode second = trailer.getPrev(); DLNode first = new DLNode(obj, second, trailer); second.setNext(first); trailer.setPrev(first); size++; } //删除首节点 public Object removeFirst() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); DLNode first = header.getNext(); DLNode second = first.getNext(); Object obj = first.getElem(); header.setNext(second); second.setPrev(header); size--; return(obj); } //删除末节点 public Object removeLast() throws ExceptionQueueEmpty { if (isEmpty()) throw new ExceptionQueueEmpty("意外:双端队列为空"); DLNode first = trailer.getPrev(); DLNode second = first.getPrev(); Object obj = first.getElem(); trailer.setPrev(second); second.setNext(trailer); size--; return(obj); } //遍历 public void Traversal() { DLNode p = header.getNext(); while (p != trailer) { System.out.print(p.getElem()+" "); p = p.getNex
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值