WinRAR命令

char str[]="c:\\Program Files\\WinRAR\\WinRAR.exe e -hp11111111 Quan1.rar";  

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,NULL,NULL,TRUE,CREATE_NO_WINDOW,NULL,NULL,&startInfo,&pidInfo);  

if(!b)  

{   

MessageBox(NULL,"failed",NULL,0);  

}

 WaitForSingleObject(pidInfo.hProcess,INFINITE);

 CloseHandle(pidInfo.hProcess);  

CloseHandle(pidInfo.hThread);

posted @ 2013-01-28 10:09  全绍辉  阅读(177)  评论(0编辑  收藏  举报