VC 命令列列印PDF檔案
阿新 • • 發佈:2019-02-04
//命令列引數CString param; param.Format(_T("/t %s"),sFilePath); SHELLEXECUTEINFO ShExecInfoPrintf = {0}; ShExecInfoPrintf.cbSize = sizeof(SHELLEXECUTEINFO); ShExecInfoPrintf.fMask = SEE_MASK_NOCLOSEPROCESS; ShExecInfoPrintf.hwnd = NULL; ShExecInfoPrintf.lpVerb = NULL; ShExecInfoPrintf.lpFile = _T("AcroRd32"); //此處是待列印的 pdf文件 ShExecInfoPrintf.lpParameters = param; ShExecInfoPrintf.lpDirectory = NULL; ShExecInfoPrintf.nShow = SW_HIDE; ShExecInfoPrintf.hInstApp = NULL; ShellExecuteEx(&ShExecInfoPrintf); //可新增 bool變數,判斷是否成功。 if (WaitForSingleObject(ShExecInfoPrintf.hProcess,5000) == WAIT_TIMEOUT) { TerminateProcess(ShExecInfoPrintf.hProcess,0); }