Calling Win32 DLL Functions from MF COBOL 
Author Message
 Calling Win32 DLL Functions from MF COBOL

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



Tue, 25 Jul 2000 03:00:00 GMT  
 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



Tue, 25 Jul 2000 03:00:00 GMT  
 Calling Win32 DLL Functions from MF COBOL

Minor correction (tripped over the dialect):

        CALL APIENTRY "MoveFileA" using
                by reference z"OldFileName"
                by reference z"NewFileName"
                RETURNING bResult
        END-CALL



Tue, 25 Jul 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. problem with mf cobol calling win32 api

2. Calling MF COBOL-DLL from VB

3. Calling C++ DLL from MF COBOL

4. REXX calling MF Cobol DLLs problem

5. MF-COBOL and DLL's: Call shows strange errors

6. calling a MF COBOL .dll (ver 3.2.50) from VB5

7. 32-bit MF COBOL DLL calling from VB4

8. Call functions in a win32 DLL

9. How to compile and link to C-DLL out of COBOL-DLL (MF)

10. Calling Win32 API functions with Gnat 3.09 (Win32 version)

11. Help on Net Express COBOL dll and calling the DLL from VB program

12. MF Cobol and OS/2 DLLs

 

 
Powered by phpBB® Forum Software