tags:

views:

163

answers:

1

Hi,

Some time ago, I had created a DLL to be used in another C program. Basically I exposed specific functions by using the following within my dll:

void __declspec(dllexport) MyFunc(myFirstArg, mySecondArg);

Then I added an external file (MyExposedDll.h) with all exposed functions and structures to the new C program and included it:

#include MyExposedDll.h

Now how can I use this dll (or mainly a dll) to a Cobol function? I need to expose a function that has two char* arguments and returns a boolean.

Thanks, Sun

+2  A: 

This should not be difficult in an IBM Z/OS environment with LE support.

Capture the boolean result using the COBOL CALL RETURNING form of the CALL statement. The string arguments are passed just as any other arguments in a COBOL CALL statement. The only thing to be wary of is that C uses Null terminated strings whereas COBOL generally does not. You should review how to handle null terminated strings in COBOL.

Have a look at: Using COBOL DLLs with C/C++ programs this gives a really simple example showing a call to a C++ function returning a function pointer.

EDIT I may have missed part of your question... When your COBOL program is linked-edited, you need to provide the your DLL IMPORT file so it can be bound. See linking DLL's.

EDIT 2

Based on your comments, I take it you are running your application on a Z/OS box. Visual Studio is a PC based product so I am guessing that you develop your code there but deploy it under Z/OS? In order to get the COBOL program to recognize your DLL you need to create a "side file" from your C program when it is compiled. This "side file" contains the DLL structures needed by the linker when the COBOL program is linked. You should be able to get the process worked out from the links provided above.

NealB
The creation of the DLL will not have any diferences, will it? I use Visual Studio 5.
Sunscreen