MFC 解压7z文件

MFC 解压7z文件

flyfish

环境需要7z.exe 和7z.dll

CString GetPath()
{
    CString  sPath;
    TCHAR szDirectory[MAX_PATH] = L"";
    ::GetCurrentDirectory(sizeof(szDirectory) - 1, szDirectory);
    sPath = szDirectory;
    return   sPath;//  不带 //
}

void Decompression()
{
    // TODO:  在此添加控件通知处理程序代码


    //解压到当前目录
    CString str7zExePath = GetPath() + _T("\\7z.exe");//7z.exe文件所在路径

    CString strSourcePath = GetPath() + _T("\\Test.7z");//解压文件的路径
    CString strDestinationDir = GetPath();

    CString strParameter;//解压参数

    strParameter.Format(_T("x %s -o%s -y"), strSourcePath, strDestinationDir); //按照7Z文件的原目录解压

    HINSTANCE hRet = ShellExecute(NULL, L"open", str7zExePath, strParameter, NULL, SW_HIDE);
    if (!hRet)
    {
        //失败
    }
    else
    {
        //成功
    }

    //x: eXtract files with full paths
    //-o{Directory}: set Output directory
    //-y: assume Yes on all queries
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

西笑生

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值