このトピックは Windows 版 FRE に適用されます。
このセクションでは、C (Objective-C) で ABBYY FineReader Engine をロードおよびアンロードする方法について説明します。
- FREngine.h ヘッダーファイルをインポートする際は、次のコードを追加します。
/* C */
#define __RPC__deref_out
#define COBJMACROS
#include <FREngine.h>
/* Objective-C */
#define interface _COM_interface
#define __RPC__deref_out
#define COBJMACROS
#import <FREngine.h>
#undef interface
- FREngine.dll の読み込みとアンロードには、次のコードを使用します。
typedef HRESULT (*initializeEngine_ptr) (BSTR, BSTR, BSTR, BSTR, BSTR, VARIANT_BOOL, IEngine **);
typedef HRESULT (*DeinitializeEngine_ptr) (void);
static IEngine* FREngine;
static HMODULE FREngineDll;
int main(int argc, char *argv[]) {
initializeEngine InitializeEngine=NULL;
DeinitializeEngine_ptr DeinitializeEngine=NULL;
// ここに Customer Project ID を指定してください。必要に応じて、オンライン ライセンス情報も指定してください
wchar_t *customerProjectId = L"";
wchar_t *licensePath = L"";
wchar_t *licensePassword = L"";
FREngineDll = LoadLibraryEx("<path to FREngine.dll>", 0, LOAD_WITH_ALTERED_SEARCH_PATH);
if(FREngineDll) {
InitializeEngine = (InitializeEngine_ptr) GetProcAddress(FREngineDll,"InitializeEngine");
if(InitializeEngine)
InitializeEngine(customerProjectId, licensePath, licensePassword, "", "", FALSE, &FREngine);
}
ProcessImage();
IEngine_Release( FREngine );
DeinitializeEngine = (DeinitializeEngine_ptr) GetProcAddress(FREngineDll,"DeinitializeEngine");
DeinitializeEngine();
}
- ABBYY FineReader Engine のその他すべての呼び出しでは、FREngine.h ヘッダーファイルで定義された C マクロを使用できます。
void ProcessImage()
{
IFRDocument* frDocument = NULL;
IEngine_CreateFRDocument( FREngine, &frDocument );
IFRDocument_AddImageFile( frDocument, L"<path to a source image>", NULL, NULL );
IFRDocument_Process( frDocument, NULL, NULL, NULL );
IFRDocument_Export( frDocument, L"<path to an output file>", FEF_PDF, NULL );
IFRDocument_Release( frDocument );
}
プログラミングに関する事項