1. 程式人生 > >VC 命令列列印PDF檔案

VC 命令列列印PDF檔案

	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);
	}
//命令列引數