Hello,

I am devoloping an Application which should run as Service on a Windows machine. The App receives Word Documents over Network and opens then over the ActiveQt and print them out.

The whole process works fine when i ran the app in debug mode ( the service with the -e option ), but when I start the service in normal operation, the word document couldn't be open. Because there is no exception or any other error message, I have no Idea where the problem might be.

When the app in serice mode tries to open the document the method querySubObject returns an NULL-Pointer.

Here is the Code of the Function which does the printing process( it runs in an own thread ):


Qt Code:
  1. void Printjob::SlotPrintDocs()
  2. {
  3. qDebug() << "Current Thread: " << currentThreadId();
  4. emit SignalAddLogEntry( QString( "Drucke: Job=%1, User=%2, Drucker=%3" ).arg( m_jobId ).arg( m_user ).arg( m_printer ) );
  5.  
  6.  
  7. if( CoInitializeEx( 0, COINIT_MULTITHREADED ) != S_OK )
  8. {
  9. emit SignalAddLogEntry( "Konnte COM-Objekt im Printjob Thread nicht initialisieren" );
  10. }
  11.  
  12. emit SignalAddLogEntry( "Starte Word" );
  13. QAxObject* pWord = new QAxObject( "Word.Application" );
  14. pWord->setProperty( "Visible", true );
  15. QAxObject* pDocuments = pWord->querySubObject( "Documents" );
  16. QString lastPrinter = pWord->property( "ActivePrinter" ).toString();
  17.  
  18. connect( pWord, SIGNAL( exception ( int, const QString&, const QString&, const QString& ) ), this, SLOT( SlotComException( int, const QString&, const QString&, const QString& ) ) );
  19. connect( pDocuments, SIGNAL( exception ( int, const QString&, const QString&, const QString& ) ), this, SLOT( SlotComException( int, const QString&, const QString&, const QString& ) ) );
  20.  
  21.  
  22. if( ! pWord || ! pDocuments )
  23. {
  24. emit SignalAddLogEntry( "Konnte Word nicht öffnen" );
  25. }
  26.  
  27. if( ! pWord->setProperty( "ActivePrinter", m_printer ) )
  28. {
  29. emit SignalAddLogEntry( "Konnte Drucker nicht wechseln" );
  30. }
  31. qDebug() << pWord->property( "ActivePrinter" ).toString();
  32.  
  33. for( int i = 0; i < m_docs.size(); i++ )
  34. {
  35. if( ! QFileInfo( m_docs.at( i ) ).exists() )
  36. {
  37. emit SignalAddLogEntry( "Konnte folgenden Dokument nicht finden: " + m_docs.at( i ) );
  38. continue;
  39. }
  40. if( ! QFileInfo( m_docs.at( i ) ).isReadable() )
  41. {
  42. emit SignalAddLogEntry( "Konnte folgenden Dokument nicht lesen: " + m_docs.at( i ) );
  43. continue;
  44. }
  45.  
  46. if( m_abortPrint )
  47. {
  48. break;
  49. }
  50.  
  51. emit SignalAddLogEntry( "Öffne Dokument: " + m_docs.at( i ) );
  52.  
  53. QVariantList params;
  54. params << m_docs.at( i ) << true << false << false << "" << "" << false << false << "" << "" << 0 << false << true << 0 << true << false;
  55. QAxObject* pDoc = pDocuments->querySubObject( "OpenNoRepairDialog (QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&, QVariant&)", params );
  56. if( ! pDoc )
  57. {
  58. emit SignalAddLogEntry( "Konnte Dokument nicht öffnen: " + m_docs.at( i ) );
  59. continue;
  60. }
  61. connect( pDoc, SIGNAL( exception ( int, const QString&, const QString&, const QString& ) ), this, SLOT( SlotComException( int, const QString&, const QString&, const QString& ) ) );
  62. emit SignalAddLogEntry( "Drucke Dokument: " + m_docs.at( i ) );
  63. pDoc->dynamicCall( "PrintOut(boolean)", false );
  64. emit SignalAddLogEntry( "Schliesse Dokument: " + m_docs.at( i ) );
  65. pDoc->dynamicCall( "Close(boolean)", false );
  66. delete pDoc;
  67.  
  68. m_printedDocs.append( m_docs.at( i ) );
  69. emit SignalSendPrintedDoc( m_docs.at( i ) );
  70. }
  71.  
  72. pWord->setProperty( "ActivePrinter", lastPrinter );
  73. qDebug() << pWord->property( "ActivePrinter" ).toString();
  74.  
  75. emit SignalAddLogEntry( "Beende Word" );
  76. pWord->dynamicCall( "Quit()" );
  77.  
  78. delete pDocuments;
  79. delete pWord;
  80. emit SignalFinishedPrinting();
  81.  
  82. if( m_abortPrint || m_docs.size() == m_printedDocs.size() )
  83. {
  84. m_pParent->deleteLater();
  85. }
  86. }
To copy to clipboard, switch view to plain text mode 
Maybe someone has some more experience with ActiveQt and an idea how can I solve this serious problem.


Ralf