🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: comp.os.ms-windows.programmer.win32
4 messages
4 total messages Started by Nils Sun, 26 Oct 2003 17:13
Calling a ActiveX function from a console application
#2148
Author: Nils
Date: Sun, 26 Oct 2003 17:13
19 lines
1935 bytes
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
Re: Calling a ActiveX function from a console application
#2149
Author: Victor Bazarov
Date: Sun, 26 Oct 2003 17:26
9 lines
1930 bytes
"Nils" <Nils.King@Software.plc.uk> wrote...
> Please could someone tell me where I am going wrong....

You're cross-posting into too many newsgroups.  Curb your
enthusiasm.  Your question has nothing to do with C++
language (which incidentally does not define anything in
the area of "MFC", "COM", "ActiveX", and other Microsoft-
specific abbreviations) and as such is off-topic in
comp.lang.c++.  Thank you.
Re: Calling a ActiveX function from a console application
#2150
Author: Boris Dynin
Date: Sun, 26 Oct 2003 22:43
57 lines
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
Re: Calling a ActiveX function from a console application
#2151
Author: K_Lee
Date: Mon, 27 Oct 2003 14:27
17 lines
2081 bytes
"Boris Dynin" <spam@noplease.com> wrote in message news:<s6Ymb.542$Wy2.8824@typhoon.sonic.net>...
> Nils,
> 
> 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.


Here's an example of how Tcl8.4.4 use it to create implement the 
ResolveShortcut() function.

http://www.slink-software.com/W/SrcDoc_Top/tcl8.4.4/tcl8.4.4.sdoc/N_72


http://www.slink-software.com/W/SL_TopGetSL/tcl8.4.4/tcl8.4.4.slk/ID_TclWinResolveShortcut/FILE_win/tclWinFile.c/L_1900/LN_1879#L_1876
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads