Calling Win32 DLL Functions from MF COBOL
Quote:
> We have a standard Windows DLL (Delphi 3) which has a number of exported
> functions contained within it.
> How do we get MF COBOL (WB 4.0) to call these functions, passing paramters
> to and getting results from?
> Cheers
I don't know Delphi but I've worked with the Win32 API. Do you have a
.LIB for the DLLs ? If you don't have a lib then you have to hand code
a .DEF file and do your own link step, otherwise you can let CBLLINK do
the work.
Another nice thing to have is some documentation on the API in any
language. Otherwise, it's reverse-engineering to determine the
parameters and call convention. There may be legal issues about doing
this kind of work.
A generic approach to calling the Win32 API:
Find the function in the Win32 SDK documentation.
Translate the C prototype to a COBOL call. If any of the call
parameters are strings, the function name probably needs an 'A' stuck on
the end to use the ASCII version rather than the UNICODE version. For
instance, MoveFile() becomes MoveFileA().
The call-convention for the Win32 API is 74.
SPECIAL-NAMES.
call-convention APIENTRY is 74.
So:
BOOL MoveFile(
LPCTSTR lpExistingFileName,
LPCTSTR lpNewFileName
);
becomes
CALL APIENTRY "MoveFileA" using
by reference z"ExistingFileName"
by reference z"NewFileName"
resulting in bResult
END-CALL
Karl Wagner