Article View: comp.os.ms-windows.programmer.win32
Article #2150Re: Calling a ActiveX function from a console application
From: Boris Dynin
Date: Sun, 26 Oct 2003 22:43
Date: Sun, 26 Oct 2003 22:43
57 lines
3350 bytes
3350 bytes
Nils, ActiveX controls have lots of plumbing inside to allow them to be used as standard controls in dialog boxes (and other windows). You can just drop an ActiveX control on dialog template in Vusual C++ (or VB). However, because of that special plumbing, ActiveX controls aren't easily used from console apps. In order to use ActiveX control, an app must act as ActiveX Container, which involves implementing quite a few COM interfaces. You probably wouldn't want to implement those "container" interfaces by hand: it's too much work. If you need an object without GUI, you could just create a COM Component. In "New ATL Object" (I assume you use VC++ 6.0) you should choose "Simple Object"; the add some interfaces to your object. COM component like the one above can be easily created from console apps. You'll have to call: CoCreateInstance() - to instantiate your component. Basically, the (simplified) flow will be like this: // Console app. // CoInitialize(NULL); MyComInterface *pCI; CoCreateInstance(..., (void**) &pCI); // Use pCI pCI->SomeMethod(); // Done with pCI pCI->Release(); CoUninitialize(); Boris "Nils" <Nils.King@Software.plc.uk> wrote in message news:cdb31147.0310260913.670c875a@posting.google.com... > Hi, > > > Please could someone tell me where I am going wrong.... > > I have a simple ActiveX object (MFC and have tried a ATL version) that > has a simple public function that I wish to call from a console > application (as a test and then from a .NET web page later on). > > When I add the COM object as a reference to the project the object > browser does not show my function and obviously won't let me use it in > the code, why is this?! - the ActiveX dll is compile and registered (I > think, do you have to 'register' functions in a special way). > > Please someone put me out of my stupidity/missery. > > Many thanks, > > -Nils
Technical Details
Message-ID:
<s6Ymb.542$Wy2.8824@typhoon.sonic.net>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.he.net!newsfeed1.easynews.com!easynews.com!easynews!sjc72.webusenet.com!news.webusenet.com!feed.news.sonic.net!typhoon.sonic.net!not-for-mailReferences:
<cdb31147.0310260913.670c875a@posting.google.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f9701,684751479369e3bb X-Google-Attributes: gidf9701,public X-Google-Thread: 105ce5,684751479369e3bb X-Google-Attributes: gid105ce5,public X-Google-Thread: 11100c,684751479369e3bb X-Google-Attributes: gid11100c,public X-Google-Thread: 113dfb,684751479369e3bb X-Google-Attributes: gid113dfb,public X-Google-ArrivalTime: 2003-10-26 14:45:14 PST Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!news.he.net!newsfeed1.easynews.com!easynews.com!easynews!sjc72.webusenet.com!news.webusenet.com!feed.news.sonic.net!typhoon.sonic.net!not-for-mail From: "Boris Dynin" <spam@noplease.com> Newsgroups: comp.os.ms-windows.programmer.win32,borland.public.cppbuilder.activex,comp.os.ms-windows.programmer.tools.misc,microsoft.public.vc.activex.templatelib References: <cdb31147.0310260913.670c875a@posting.google.com> Subject: Re: Calling a ActiveX function from a console application Lines: 59 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 Message-ID: <s6Ymb.542$Wy2.8824@typhoon.sonic.net> Date: Sun, 26 Oct 2003 22:43:36 GMT NNTP-Posting-Host: 64.142.36.135 X-Complaints-To: abuse@sonic.net X-Trace: typhoon.sonic.net 1067208216 64.142.36.135 (Sun, 26 Oct 2003 14:43:36 PST) NNTP-Posting-Date: Sun, 26 Oct 2003 14:43:36 PST