Board index » delphi » How to register OLE Automation server from the client

How to register OLE Automation server from the client

How do I register a typelibrary from my client i Delphi 3?
I know that you can use the Windows API-procedure RegisterTypeLib, but
does
Delphi 3 have a procedure in fx. the ComObj-unit.
If not how do I use the RegisterTypeLib ?

Regards,
    Lasse, dk

 

Re:How to register OLE Automation server from the client


Quote
Lasse Holm wrote in message <6psft5$n...@forums.borland.com>...
>How do I register a typelibrary from my client i Delphi 3?
>I know that you can use the Windows API-procedure RegisterTypeLib, but
>does
>Delphi 3 have a procedure in fx. the ComObj-unit.
>If not how do I use the RegisterTypeLib ?

>Regards,
>    Lasse, dk

You can register your typlib by 2 ways: deploying your tlb with the project
or include it in a ressource.

With the tlb file, you can use something like :

procedure registerMyTipLib
var
 Name:WideString;
 TypeLib : ITypeLib;
begin

 Name := ExtractFilePath(Application.ExeName)+'file.TLB';
 OleCheck(LoadTypeLib(PWideChar(Name), TypeLib));
 OleCheck(RegisterTypeLib(TypeLib, PWideChar(Name), Nil));

end;

in your code.

The second way is to directly import your typelib in a ressource and link it
with your Project:
put a {$R PATH\FILE.TLB} in your project.When compiled, your exe will have
the typpelib in a ressource and you can directly use a :

       ComServer.LoadTypeLib;
       ComServer.UpdateRegistry(true);

even if your exe is not a com server. The only problem you may have is if
your client application already have an other type lib: delphi3 can not
handle multiple type libraries in ressources.

Regards.

Re:How to register OLE Automation server from the client


Thank you very much for your answer.
You will make my day, if you can tell me how to change the filepath of
the EXE-file, which is run when calling a OLE automation method.
The reason to register the server from the client is that I want to
make sure, that one particular server is startet. (There can be more
than one server-exe-file on the same system and it is essential that
it is the  right one which is started up)
Regards
Quote
defrance frederic wrote in message <6psm8h$n...@forums.borland.com>...

Re:How to register OLE Automation server from the client


Quote
defrance frederic wrote:

> put a {$R PATH\FILE.TLB} in your project.When compiled, your exe will have
> the typpelib in a ressource and you can directly use a :

>        ComServer.LoadTypeLib;
>        ComServer.UpdateRegistry(true);

> even if your exe is not a com server. The only problem you may have is if
> your client application already have an other type lib: delphi3 can not
> handle multiple type libraries in ressources.

Can multiple type libraries exist in the same project with Delphi 4?

I have an application with a main exe that is Delphi with some
supporting dlls that are VC++ ATL based.  I want the COM objects from
both to be viewable by a client as one set of objects.  Can I do this
with D3 or D4?

Thanks,

John

Other Threads