以下の例では、CALL ステートメントを使用して C/C++ ダイナミック・リンク・ライブラリー (DLL) を呼び出す COBOL プログラムを示しています。
この例では、以下の概念を示しています。
以下のステップを実行して、サンプルを作成して実行します。
#include <windows.h>
#include <string.h>
#include <stdio.h>
BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD,LPVOID);
_declspec (dllexport) int Sub(void);
BOOL WINAPI DllMain (
HANDLE hModule,
DWORD dwFunction,
LPVOID lpNot)
{
return TRUE;
}
_declspec (dllexport) int Sub(void)
{
printf (“Hello from sub.\n”);
return 0;
} LIBRARY Sub
EXPORTS
Subcl /EHsc /LD /DLL /DEF:sub.def sub.ccbl CALLINT(CDECL),PGMNAME(MIXED),LIST
Identification Division.
Program-Id. “Driver”.
Data Division.
Working-Storage Section.
77 rc pic 9(8) usage binary.
Procedure Division.
Display “Hello World, from Driver”
Call “Sub” returning rc
Display “Sub Returned to Driver”
Goback.cob2 -g -v driver.cbl -IMP:sub.lib関連タスク
ダイナミック・リンク・ライブラリーの構築
関連参照
cob2 オプション
CDECL
CALL ステートメント
(「COBOL for Windows 言語解説書」)