Board index » delphi » Automation client in D5 DLL

Automation client in D5 DLL

Is it possible to allow a program written in a language that does not
support COM to have access to the services of an automation server by
calling a Delphi 5 DLL that creates the automation object and uses its
methods?

The same code that works from an EXE file raises an exception when
performed from within a DLL.

 Any tips on how to do this from a DLL will be welcome.

Thanks

Gerry

 

Re:Automation client in D5 DLL


Your simply wrapping an api dll over the top of com executed calls.  If you
know how to create a dll, and export procedures,
and know how to call a com object etc.. then there's not really much else
too it.
One tip would be you'd have to manage Initialization of the Com Library by
calling CoInitialize and CoUninitialize.
This could be within the Initialization and Finalization of you Dll main
unit.

Start by created an exported procedure or function and do something like..

procedure TestCallingComObject(InputA: Integer; var ResultA: Integer);
{Calling Convention};
var
    MyObject: IMyObject;
begin
    CoInitialize(NIL);
    try
        MyObject := CoMyObject.Create;
        try
            ResultA := MyObject.TestGetSomeResult(InputA);
        finally
            MyObject := NIL;
        end;
    finally
        CoUninitialize;
    end;
end;

Later

Chris.

Quote
"John" <J...@in.net> wrote in message

news:3bcdbe45.21773618@forums.inprise.com...
Quote
> Is it possible to allow a program written in a language that does not
> support COM to have access to the services of an automation server by
> calling a Delphi 5 DLL that creates the automation object and uses its
> methods?

> The same code that works from an EXE file raises an exception when
> performed from within a DLL.

>  Any tips on how to do this from a DLL will be welcome.

> Thanks

> Gerry

Other Threads