Consultor Eletrônico



Kbase 13146: Using CDECL to access variable number of arguments in DLL
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
Using CDECL to access variable number of arguments in DLL

Using CDECL to access DLL routines with variable number of arguments
------------------------------------------------------------------------

Some DLL entry points use C language calling conventions. This
convention is most often used because the DLL entry point allows
a variable number of arguments. For example, a DLL entry point like
wsprintf() can be called with a different number of arguments each time
you call it. If you first call wsprintf() with 2 arguments, then
you must declare the entry point with the two types of arguments
that you will use. If later in your Progress program you want to
call wsprintf() with 3 arguments, then you must have declared the
entry point a second time with those 3 argument types. (See External
Program Interfaces Guide Chapter 4 for details).

The way to declare the same entry point more than once in the same
Progress program is to give each one a different proc-name but
still reference the same external DLL entry point using the
Ordinal number associated with that DLL entry point.

For example:
PROCEDURE wsprintf1 EXTERNAL 'dllname' CDECL ORDINAL n:
parm 1 definition...
parm 2 definition...

END.

PROCEDURE wsprintf2 EXTERNAL 'dllname' CDECL ORDINAL n:
parm 1 definition...
parm 2 definition...
parm 3 definition...
END.

Now you can use access the wsprintf() entry point in the DLL in two
different ways:

RUN wsprintf1 arg1 arg2.
OR
RUN wsprintf2 arg1 arg2 arg3.

Progress Software Technical Support Note # 13146