Consultor Eletrônico



Kbase P85039: How to pass a parameter of type IUNKNOWN to a DLL call ?
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   7/16/2004
Status: Unverified

GOAL:

How to pass a parameter of type IUNKNOWN to a DLL call ?

GOAL:

How to pass a COM-HANDLE to a DLL function ?

FIX:

IUknown is a custom datatype which actually matches the COM-HANDLE 4GL datatype.

It is not possible to pass a COM-HANDLE directly into a DLL function; the 4GL simply does not have the means to map the datatypes.

However, as the COM-HANDLE is in fact a direct pointer to the object, it is possible to pass it into a DLL function by converting it to an integer first:

A) in the dll function declaration, declare the IUnknown parameters as LONG.
B) when passing the COM-HANDLE to the function, convert it to integer first using the INTEGER() function.

Note that there are other considerations that should be taken into account such as managing the reference count of the COM object properly. Failing to do so will lead to unpredictable results and/or GPFs.