2011-12-03 29 views
0

はシナリオです:印刷生データはここ

  • 私は、私は、Windows XPを使用してクライアントマシンを持って
  • (NOドメインコントローラ、ありませんが、ドメインに参加していない)ターミナルサーバーでWindows Server 2008を持っていますSP3更新(.NET 3.0 SP1および.NET 4.0)
  • 私はチケットプリンタ(などサーマルプリンタ、POSプリンタ、エプソン、シマウマを)持っているエンバカデロC++ Builderの(BCB6)
  • を使用しています

ターミナルサーバーに接続すると、プリンタは正常に動作します。テストページの印刷をテストしました。

私はローカルコンピュータ上のターミナルサーバーでの生データを送信するために、私のソフトウェアを使用する場合、私はこのエラーを取得:

Windows Presentation Foundation terminal server print W has encountered a 
problem and needs to close. We are sorry for the inconvenience. 

私は運でこれsupport pageからの助言に従いました。

私はLPT1:に直接印刷していましたが、Windows Server 2008ではこの作業を行うのが難しくなりましたので、この種類のプリンタに印刷する方法を変更する必要があります。

ここに私が使用しているコードがあります。私はローカルでテストしても問題なく動作しますが、ターミナルサーバーでは機能しません。

bool TForm1::RawDataToPrinter(char* szPrinterName, char* lpData, unsigned int dwCount) 
{ 
    int BytesWritten; 
    HANDLE hPrinter; 
    TDocInfo1 DocInfo; 
    bool bStatus = false; 
    int dwJob = 0; 
    unsigned long dwBytesWritten = 0; 

    // Open a handle to the printer. 
    bStatus = OpenPrinter(szPrinterName, &hPrinter, NULL); 

    if(bStatus) 
    { 
     // Fill in the structure with info about this "document." 
     DocInfo.pDocName = "My Document"; 
     DocInfo.pOutputFile = NULL; 
     DocInfo.pDatatype = "RAW"; 

     // to indicate that the application will be sending document data to the printer. 
     dwJob = StartDocPrinter(hPrinter, 1, (LPBYTE)&DocInfo); 

     if (dwJob > 0) 
     { 
      // Start a page. 
      bStatus = StartPagePrinter(hPrinter); 
      bStatus = true; 

      if(bStatus) 
      { 
       // Send the data to the printer. 
       bStatus = WritePrinter(hPrinter, lpData, dwCount, &dwBytesWritten); 
       EndPagePrinter (hPrinter); 
      } 

      // Inform the spooler that the document is ending. 
      EndDocPrinter(hPrinter); 
     } 
     // Close the printer handle. 
     ClosePrinter(hPrinter); 
    } 
    // Check to see if correct number of bytes were written. 
    if (!bStatus || (dwBytesWritten != dwCount)) 
     bStatus = false; 
    else 
     bStatus = true; 

    return bStatus; 
} 

このコードは、Microsoftのサポートの例からコピーしました。私も "RAW"を "TEXT"に変更しようとしましたが、同じエラーが発生します。

それは印刷するGDIを使用していますので、私は、このコードを試してみました:

long pageline; 

char prueba[255]; 

Printer()->SetPrinter(ListBox1->Items->Strings[ListBox1->ItemIndex].c_str(), "WINSPOOL", "", NULL); 
Printer()->BeginDoc(); 

pageline = 0; 
while(pageline < Memo1->Lines->Count) 
{ 
    Printer()->Canvas->TextOut(10, (10 + Printer()->Canvas->TextHeight("Hi! There")) * pageline, Memo1->Lines->Strings[pageline]); 
    pageline++; 
} 

Printer()->EndDoc(); 

これは私がエンバカデロフォーラムで見つかった例です。

また、TsWpfWrp.exeも確認しました。私はそれをサーバーのものに置き換えようとしましたが、何もしません、エラーを送信しませんが、データを送信しません。

これを行う別の方法がありますか?コードに何か問題がありますか?

私は助けや洞察力に感謝しました。

答えて

1

Easy Printドライバが問題を見つけました。RAWモードではXPS仕様を期待していましたが、テキストのみを送信していました。

Easy Printを無効にしてプリンタをFallbackモードにすると、ターミナルサーバーが最初にインストールされたドライバを探してからEasy Printを探します(これは以下のプロパティで確認できます)。プリンタの詳細オプション)。

今、感謝します。

関連する問題