?
Solved

How to stop Delphi registering COM objects

Posted on 2003-02-20
5
Medium Priority
?
500 Views
Last Modified: 2011-09-20
I am writing a DLL in Delphi that serves COM objects to a Python script.  Python is basically an interpreted language and accesses the COM objects using using IDispatch.  As far as I can tell, the only way to write IDispatch objects in Delphi is to write dual-interfaced automation objects.  I use File->New->ActiveX->Automation Object to create them because that's the only thing that seems to work for me.

Although the DLL provides many COM objects, I want the DLL to register only the top-level object (IServer).  The python script makes calls on IServer to get the other objects, so no registration is necessary for them.

Unfortunately, when I create automation objects as above, Delphi adds a TAutoObjectFactory.Create to the initialization section for every unit.  In consequence all the interfaces get registered.  I can't comment out this bit because it causes TAutoObject.Create to fail.  I suppose I could derive a new class factory from TAutoObjectFactor and the override the UpdateRegistry method to do nothing, but this seems ugly.  Surely there is a better way.

So my question is this: Is there a proper way to serve IDispatch interfaces in Delphi without Delphi attempting to register them?
0
Comment
Question by:oliverbock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 21

Expert Comment

by:ziolko
ID: 7992131
You can do it other way:
New -> ActiveX -> ActiveX Library then
New -> ActiveX -> Type Library
then there will be no auto created COMs.
Or other way is:
New -> Unit
this unit should look like this:

unit UEntryPoint;

interface

uses ComServ;

function DllGetClassObject(const CLSID, IID: TGUID; var Obj): HResult; stdcall;
function DllCanUnloadNow: HResult; stdcall;
function DllRegisterServer: HResult; stdcall;
function DllUnregisterServer: HResult; stdcall;


implementation

uses AddIn, webdcsrvtool_TLB, ActiveX;

const
        S_OK    = $00000000;

function DllGetClassObject(const CLSID, IID: TGUID; var Obj): HResult;
begin
  // do here custom DLL Load
  Result:=ComServ.DllGetClassObject(CLSID,IID,Obj);
end;

function DllCanUnloadNow: HResult;
begin
  // custom DLL UnLoad
  Result:=ComServ.DllCanUnloadNow;
end;

function DllRegisterServer: HResult;
begin
  Result:=ComServ.DllRegisterServer;
  //custom register
end;

function DllUnregisterServer: HResult;
begin
  // custom UnRegister
  Result:=ComServ.DllUnregisterServer;
end;

end.

then go to project file and change ComServ with UEntryPoint.
ziolko.
0
 

Author Comment

by:oliverbock
ID: 8012807
While ziolko's comment shows me how to create a COM server that doesn't export anything, it doesn't solve my problem.  It doesn't tell me how to implement an IDispatch object that doesn't register itself.
0
 

Accepted Solution

by:
oliverbock earned 0 total points
ID: 8023247
It turns out that there is a simple way to do this: select "Internal" as the Instancing type in the Automation Object Wizard.  (You get to this wizard when creating new automation objects via File->New->ActiveX->Automation Object)  This supplies the ciInternal flag to the TAutoObjectFactory constructor.
0
 

Expert Comment

by:CleanupPing
ID: 9317147
oliverbock:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

Introducing Priority Question

Increase expert visibility of your issues by participating in Priority Question, our latest feature for Premium and Team Account holders. Adjust the priority of your question to get emergent issues in front of subject-matter experts for help when you need it most.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question