Solved

Work with a COM object using CLSID

Posted on 2002-07-10
8
537 Views
Last Modified: 2008-02-01
In my COm object implementation, there is this chunk of code:

initialization
  TAutoObjectFactory.Create(ComServer, TBrowser, Class_Browser, ciInternal, tmApartment);

1. Does an instance of TBrowser is created automatically at the stratup of my application?
2. What if I want to use this instance of the object inside my application and not creating another instance?
3. Can it have something to do with GetActiveOleObject?
0
Comment
Question by:pjroy
8 Comments
 
LVL 26

Expert Comment

by:Russell Libby
ID: 7144694
prjoy,

1.) The code you are describing above does not create an instance of your com class. It creates an instance of a class factory FOR your com class (gets added to the factory list in the ComClassManager.)

2.) See 1

3.) No, GetActiveOleObject (wrapper to GetActiveObject) requires that the COM class be previously registered using RegisterActiveObject.

What is it exactly that you are trying to achieve? Do you only wish one instance of you com class to be loaded by other clients? Or is your application creating an instance of the class, and you wish to get a reference to it?

Russell


0
 

Author Comment

by:pjroy
ID: 7144893
Russell,

Want I want to do is to have only one instance of my COM object. The help you better understand the problem, the application has a Microsoft Money 2002 like GUI. The methods call come from either a JavaScript call through an html pages hosted by TWebBrowser, secondly from the inside of the host (Delphi code). I don't want to write a Delphi object model with a COM wrapper if it is possible for me to build everything into COM object and then using them from JavaScript and Delphi. Remember, its a standalone application and no calls come from the outside. I use window.external in Javascript to access the COM interface exposed by my application.

Thanks

0
 
LVL 26

Expert Comment

by:Russell Libby
ID: 7146174

prjoy,

Is the COM object that your trying to create/share located in your EXE? (Is your app an OLE server). Or is the COM object located in a seperate EXE/DLL?

If in a seperate DLL/EXE, then your host EXE would simply be able to create an instance of the COM object (on startup, or where appropriate). Then when IDocHostUIHandler.GetExternal() gets called, you would pass the reference back to the web browser. This would allow both your host (delphi code) and the web browser script code to access/manipulate the same object.

If your app is an OLE server, which according to your above comment its not (quote: Remember, its a standalone application and no calls come from the outside) then things get a little more interesting. If this is the case, then let me know.

Sorry I can't help more, but it would help if you described where the COM object is located (in your exe, or some other dll/exe)

Russell
 
0
ScreenConnect 6.0 Free Trial

Check out the updates in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI that improves session organization and overall user experience. See the enhancements for yourself!

 

Author Comment

by:pjroy
ID: 7146241
The COM is in the same EXE for now. After my project advance, I will possibly refactor and create dll if I need to. What is the difference between those two cases?
0
 

Author Comment

by:pjroy
ID: 7146253
Sorry, I've written my question before reading your entire answer. I'll increase your point when I'll be back in 2 days and had time to test the concept. Back soon.

Thanks
0
 
LVL 26

Accepted Solution

by:
Russell Libby earned 100 total points
ID: 7146324
prjoy,

Being an OLE server makes a difference, because you may be controlled by another app. The the instancing comes into play (is there already an interface, etc..). Looking at the first comment though:

TAutoObjectFactory.Create(ComServer, TBrowser, Class_Browser, ciInternal, tmApartment);

assures that you will not be. The ciInternal tells delphi NOT to register this class factory with COM, thus no app can get an instance of this interface (other than your own app).

So...
In your app code
1.) in your host, include both the source unit and tlb unit
2.) var (or make property of form, or whatever)
    pbrowser:   IBrowser;
3.) in FormCreate() (or applicable place)
    pbrowser:=TBrowser.Create;
4.) In GetExternal()
    return pbrowser
5.) Your host can also use the pbrowser variable to access the interface (which i assume in turn accesses your application/form/etc...)

Russell



0
 

Expert Comment

by:CleanupPing
ID: 9343076
pjroy:
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
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9460836
pjroy,
No comment has been added lately (18 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to rllibby http:#7146324

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Internet Explorer View Settings Question 15 111
Run video youtube webbrowse 10 62
Graphics32 under Delphi 10.1 Berlin 2 68
Delphi: sending SMS on android platform 1 21
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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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