之前用C#实现过,把整个文件夹加密压缩成RAR文件,
因为用C#需要安装.Net Frame Work.用起来很不方便,所以想使用C++来实现.
请弄过这部分的朋友介绍下,谢谢
//把指定文件夹加密压缩成RAR文件
private void zipFile()

//要压缩的文件夹路径 D:\\test\\
string filePath = @"D:\test";//压缩后的文件夹路径 D:\\test.rar
zipFileName = "test";
rarPath = @"D:\" + zipFileName + ".rar"; System.Diagnostics.Process process1 = new System.Diagnostics.Process();
process1.StartInfo.FileName = "Winrar.exe";
process1.StartInfo.CreateNoWindow = true;//调用Winrar.exe进程加密压缩  密码是 10086
process1.StartInfo.Arguments = " a -p10086 " + rarPath + " " + filePath;
process1.Start();Thread.Sleep(3000);
}

解决方案 »

  1.   

    #include <stdio.h>
    #include <stdlib.h>
    int main()
    {
    //提示rar不是内部或外部命令!!!
    system("Winrar.exe a -p123123 d:\test.rar d:\test\ ");getch();
    return 0;
    }
      

  2.   

    //控制台程序 test.c#include <stdio.h>
    #include <stdlib.h>
    #include <stdio.h>
    #include <windows.h>int main()
    {
    int bRet;

    PROCESS_INFORMATION pi;
    STARTUPINFO si;
    memset(&si,0,sizeof(si));
    si.cb=sizeof(si);
    si.wShowWindow=SW_SHOW;
    si.dwFlags=STARTF_USESHOWWINDOW;

    bRet =  CreateProcess(NULL,

    //第二个参数设为notepad返回1,并且可以打开一个记事本
    //设置为winrar返回0, 无法打开Winrar.exe进程
    //但是在 "开始-->运行"中可以打开
    "notepad",  //winrar  notepad NULL,
    FALSE,
    NULL, 
    NULL, 
    NULL, 
    NULL,
    &si,
    &pi);

        printf("bRet = %d \n", bRet);

    getch();
    return 0;
    }