[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

How to stop Delphi registering COM objects

Posted on 2003-02-20
5
Medium Priority
?
512 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
  • 2
4 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video tutorial shows you the steps to go through to set up what I believe to be the best email app on the android platform to read Exchange mail.  Get the app on your phone: The first step is to make sure you have the Samsung Email app on your …
In this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.

590 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