|
那天在写个东西的时候要先解压文件,呵呵,虽然这个算法到处都有,但是客户都使用windows操作系统,所以就想到我winrar,不就结了.余是就先查看了一下它的帮助文件,先把它在命令行下的参数搞懂 于是就开始调用,先想到的是shell .但是后来突然发现它对中文的情况支持有问题,哎,我也不晓得该怎么整,于是改了种方法.程序代码片段如下:
int icount=m_LC.GetItemCount(); // CString cmd_str; // cmd_str="C:\Program Files\WinRAR\WinRAR.exe"; // cmd_str=cmd_str+" e "; // cmd_str=cmd_str+"C:\aa.zip"; // cmd_str=cmd_str+" C:\aa\"; //system(cmd_str); //::she m_progress.SetRange(1,icount); for(int i=0;i<icount;i++) { //cmd_str=" "; //cmd_str="c:\\Program Files\\WinRAR\\WinRAR.exe e "; //cmd_str+=file_list.GetItemText(i,1); //cmd_str+=" "; //cmd_str+=Get_drection(file_list.GetItemText(i,1)); //cmd_str+="\\"; //MessageBox(cmd_str); //::ShellExecuteEx(cmd_str); //::system(cmd_str); //this->m_test=cmd_str; if(check(m_LC.GetItemText(i,1))) { CString str="\""+m_LC.GetItemText(i,1)+"\""; str+=" \""+Get_drection(m_LC.GetItemText(i,1))+"\\\""; str=get_direct()+" x -o+ -IBCK "+str; PROCESS_INFORMATION pidInfo; STARTUPINFO startInfo; BOOL b; char *buf=" "; startInfo.cb = sizeof(STARTUPINFO); startInfo.lpReserved = NULL; startInfo.lpTitle = NULL; startInfo.lpDesktop = NULL; startInfo.dwX = 0; startInfo.dwY = 0; startInfo.dwXSize = 0; startInfo.dwYSize = 0; startInfo.dwXCountChars = 0; startInfo.dwYCountChars = 0; startInfo.dwFlags = STARTF_USESTDHANDLES; startInfo.wShowWindow = 0; //SW_SHOWDEFAULT; startInfo.lpReserved2 = NULL; startInfo.cbReserved2 = 0; startInfo.hStdInput = GetStdHandle(STD_INPUT_HANDLE); startInfo.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); startInfo.hStdError = GetStdHandle(STD_ERROR_HANDLE); b=CreateProcess(NULL,str.GetBuffer(0),NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,NULL,&startInfo,&pidInfo); if(!b){ AfxMessageBox("failed"); return; } str.ReleaseBuffer(); WaitForSingleObject(pidInfo.hProcess,INFINITE); CloseHandle(pidInfo.hProcess); CloseHandle(pidInfo.hThread); } else { MessageBox("该文件非压缩文件哦::"+m_LC.GetItemText(i,1)); } m_progress.SetPos(i+1);
搞定,没发现怎么问题 呵呵 : )
|
一共有 4 条评论
get_direct()
这两个函数干什么的啊???
给我发一个吧
谢谢啊
gshzyfx@163.com
呵呵,十分感谢!