Performing Pull Stored Print Management Example for C++ 6.0 and later

void PerformPullStoredPM()
{
   ILEADDicomPrintSCUPtr spPrintSCU(__uuidof(LEADDicomPrintSCU));

   // The sink
   //CPrintSCUSink PrintSCUSink(spPrintSCU);

   char szMsg[32];

   // Establish the Association
   short nRet = spPrintSCU->Associate("10.0.2.20", 7104, "PrintSCP", "PrintSCU",
                                      DicomClassEnum(
                                      PRNSCU_PULL_STORED_PM_META_SOP_CLASS +
                                      PRNSCU_PRINT_JOB_SOP_CLASS +
                                      PRNSCU_PRINTER_CONFIGURATION_RETRIEVAL_SOP_CLASS));
   if (nRet == DICOM_ERROR_PRINTSCU_ASSOCIATE_RQ_REJECTED)
   {
      wsprintf(szMsg, "Source = %hd, Reason = %hd",
               spPrintSCU->AssociateRejectSource, spPrintSCU->AssociateRejectReason);
      MessageBox(NULL, szMsg, "Association Request was Rejected", MB_OK);
      return;
   }
   else if (nRet != DICOM_SUCCESS)
   {
      wsprintf(szMsg, "Error code: %hd", nRet);
      MessageBox(NULL, szMsg, "Failed to Establish the Association", MB_OK);
      return;
   }

   // Display some printer info
   //GetPrinterInfo(spPrintSCU->Printer);

   // Display some printer configuration info
   //GetPrinterConfigInfo(spPrintSCU->PrinterConfiguration);

   ILPullPrintRequestPtr spPullPrintReq = spPrintSCU->PullPrintRequest;

   // A referenced Stored Print Storage SOP Instance
   spPullPrintReq->RemoveAllStoredPrintItems();
   spPullPrintReq->AddStoredPrintItem("SomeAE",
                                      "1.2.840.114257.254.7638.6787",
                                      "1.2.840.114257.945.5676.5674",
                                      "1.2.840.114257.23.2343.3489",
                                      "SomeID");

   // Ask the Print SCP to create a Pull Print Request SOP Instance
   spPullPrintReq->IncludedParameters = PPR_NUMBER_OF_COPIES;
   spPullPrintReq->NumberOfCopies = 1;
   spPullPrintReq->Create();
   MessageBox(NULL, spPullPrintReq->SOPInstanceUID, "Pull Print Request SOP Instance UID", MB_OK);

   // Print the session
   spPullPrintReq->PrintSession();

   // Display some info about the Print Job
   if (spPrintSCU->IsClassSupported(PRNSCU_PRINT_JOB_SOP_CLASS))
   {
      //GetPrintJobInfo(spPrintSCU->PrintJob, spPullPrintReq->PrintJobSOPInstanceUID);
   }

   // Ask the Print SCP to delete the Pull Print Request SOP Instance
   spPullPrintReq->Delete();

   // Release the Association and close the connection
   spPrintSCU->ReleaseAssociation();
}