全てのBCL のCOM オブジェクト、は様々なプログラム環境からアクセスすることが可能です。このセクションではCOM オブジェクトとそれらへのアクセス方法の基本を紹介します。既にCOM オブジェクトの使用に関してご存知の場合、サンプルコードの章へスキップして実際の作業を開始してください。
この例はVisual C# またはVisual Basic.NET からCOM オブジェクトへのアクセス方法を紹介しています。

| using
BCL.easyPDF6.Interop.easyPDFPrinter; // ... Printer oPrinter = null; PrintJob oPrintJob = null; try { Type type = Type.GetTypeFromProgID("easyPDF.Printer.6"); oPrinter = (Printer)Activator.CreateInstance(type); oPrintJob = oPrinter.PrintJob; oPrintJob.PrintOut(inFileName, outFileName); } catch(System.Runtime.InteropServices.COMException err) { // ... } |
| Imports
BCL.easyPDF6.Interop.easyPDFPrinter ' ... Dim oPrinter As Printer = Nothing Dim oPrintJob As PrintJob = Nothing Try oPrinter = CreateObject("easyPDF.Printer.6") oPrintJob = oPrinter.PrintJob oPrintJob.PrintOut(inFileName, outFileName) Catch ex As System.Runtime.InteropServices.COMException ' ... End Try |
この例はVisual Basic からCOM オブジェクトへのアクセス方法を紹介しています。

| Sub
Convert(inFileName As String, outFileName As String) Dim oPrinter As easyPDFPrinter.Printer Dim oPrintJob as easyPDFPrinter.PrintJob On Error GoTo Convert_Error Set oPrinter = CreateObject("easyPDF.Printer.6") Set oPrinjob = oPrinter.PrintJob Call oPrintJob.PrintOut(inFileName, outFileName) Exit Sub Convert_Error: ' ... End Sub |
この例はVisual C++ からCOM オブジェクトへのアクセス方法を紹介しています。
| #import "C:\Program Files\Common Files\BCL Technologies\easyPDF 6\bepprint.dll" |
| HRESULT
hr = CoInitialize(NULL); if(FAILED(hr)) { // failed. // ... } |
| easyPDFPrinter::IPrinterPtr pPrinter =
NULL; easyPDFPrinter::IPrintJobPtr pPrintJob = NULL; try { pPrinter.CreateInstance(_T("easyPDF.Printer.6")); pPrintJob = pPrinter->GetPrintJob(); pPrintJob->PrintOut(lpInFileName, lpOutFileName); } catch(_com_error &e) { // ... } |
| //
IMPORTANT: // Make sure to free all COM objects before calling // CoUninitialize(), or you'll get an exception. pPrinter = NULL; pPrintJob = NULL; CoUninitialize(); |
この例はWindows スクリプティングホストからCOM オブジェクトへのアクセス方法を紹介しています。
| <?xml version="1.0"
encoding="UTF-8" standalone="yes" ?> <package> <job id="demo"> <?job error="true" debug="true" ?> <object id="PrinterSDK" progid="easyPDF.Printer.6" reference="true" /> <script language="VBScript"> <![CDATA[ Set oPrinter = CreateObject("easyPDF.Printer.6") Set oPrinjob = oPrinter.PrintJob Call oPrintJob.PrintOut(inFileName, outFileName) ]]> </script> </job> </package> |