标签:filename stat tar hresult close col wait ali uuid
1 CoInitializeEx(0, COINIT_MULTITHREADED); 2 3 IXpsOMObjectFactory *xpsFactory; 4 5 HRESULT hr = CoCreateInstance(__uuidof(XpsOMObjectFactory), NULL, CLSCTX_INPROC_SERVER,__uuidof(IXpsOMObjectFactory),reinterpret_cast<LPVOID*>(&xpsFactory)); 6 7 IXpsOMPackage *package = NULL; 8 9 std::tstring tstrFilename = _T("C:\\MyXPSFile.xps"); 10 11 hr = xpsFactory->CreatePackageFromFile((LPCTSTR)tstrFilename.c_str(),FALSE,&package); 12 13 HANDLE completionEvent = CreateEvent(NULL, TRUE, FALSE, NULL); 14 15 IXpsPrintJob *job = NULL; 16 IXpsPrintJobStream *jobStream = NULL; 17 18 StartXpsPrintJob(_T("MyPrinter"),_T("Print Job 1"), NULL, NULL, completionEvent, NULL, 0, &job, &jobStream, NULL); 19 20 hr = package->WriteToStream (jobStream, FALSE); 21 22 hr = jobStream->Close(); 23 24 if (completionEvent != NULL) 25 { 26 if (WaitForSingleObject(completionEvent, INFINITE) == WAIT_OBJECT_0) 27 { 28 XPS_JOB_STATUS jobStatus; 29 hr = job->GetJobStatus(&jobStatus); 30 } 31 32 CloseHandle(completionEvent); 33 completionEvent = NULL; 34 } 35 36 jobStream->Release(); 37 jobStream = NULL; 38 39 job->Release(); 40 job = NULL; 41 42 package->Release(); 43 package = NULL;
标签:filename stat tar hresult close col wait ali uuid
原文地址:https://www.cnblogs.com/guozht/p/11256090.html