microsoft / Windows-driver-samples

This repo contains driver samples prepared for use with Microsoft Visual Studio and the Windows Driver Kit (WDK). It contains both Universal Windows Driver and desktop-only driver samples.
Microsoft Public License
6.99k stars 4.94k forks source link

Retrieving PrintTicket for shared XPS driver failes (returns PrintTicket of local computer) #362

Open wstaelens opened 5 years ago

wstaelens commented 5 years ago

When retrieving the PrintTicket from a shared XPS v4 driver, you get the PrintTicket of the local computer and not of the computer who printed to the shared driver.

The IPrintPipelinePropertyBag contains the incorrect information. The user can be found when parsing the xps datastream itself.

Either this is a bug, or documentation should be improved as it is not clear then what we are doing wrong.

__override STDMETHODIMP StreamFilter::InitializeFilter(
    _In_    IInterFilterCommunicator         *pIFilterCommunicator,
    _In_    IPrintPipelinePropertyBag        *pIPropertyBag,
    _In_    IPrintPipelineManagerControl     *pIPipelineControl
    ){
…
m_JobInfo = new JobInformation(pIPropertyBag);
}

void JobInformation::SavePrintTicket(CString outputFolder)
{
SafeVariant varUserPrintTicket;
VariantInit(&varUserPrintTicket);
THROW_ON_FAILED_HRESULT(m_pIPropertyBag->GetProperty(XPS_FP_USER_PRINT_TICKET, &varUserPrintTicket));
IUnknown_t pUnk = varUserPrintTicket.punkVal;

IPrintReadStreamFactory_t pStreamFactory;
THROW_ON_FAILED_HRESULT(pUnk.QueryInterface(&pStreamFactory));

//
// Get the default user Print Ticket stream
// and wrap it in an IStream
//
IPrintReadStream_t pUserPrintTicketStream;
THROW_ON_FAILED_HRESULT(pStreamFactory->GetStream(&pUserPrintTicketStream));

DumpPrintTicket(pUserPrintTicketStream, outputFolder);
}
wstaelens commented 1 year ago

@elvis-sun what do you mean? I think the provided info is clear enough.