Board index » cppbuilder » Creating NT service serving as COM server

Creating NT service serving as COM server

I need to create NT service wich retrieves some data from web site
periodicaly and stores it in database.
This was done without problems. Now I want to control the service parameters
and viewing retrived data snapshot.
I tried to include COM server in the service wich gains access to this data.
But when I try to connect COM client
to the server it starts a new copy of server EXE if I create object using
CoClassCreator or get NULL interface trying
to connect to running service by ActiveInstance method of TCOMIMyInterface
object:
---------- code sample ----------
TCOMIMyInterface itf;

bool __fastcall TForm2::GetData()
{
       itf = CoMyClass::Create();
........
// itf is OK, but it starts new EXE

-------- another sample --------
TCOMIMyInterface itf;

bool __fastcall TForm2::GetData()
{
       itf .ActiveInstance( CLSID_MyClass );
// get itf.intf == 0
----------------------------------
Has this problem any solution?

 

Re:Creating NT service serving as COM server


You need to add the Key "LocalService" to your AppID registry key for your
COM class. You also need to make the Class Factory a Singleton

Quote
"???? e??" <Pivova...@Polyplastic.ru> wrote in message

news:3a4338a0_1@dnews...
Quote
> I need to create NT service wich retrieves some data from web site
> periodicaly and stores it in database.
> This was done without problems. Now I want to control the service
parameters
> and viewing retrived data snapshot.
> I tried to include COM server in the service wich gains access to this
data.
> But when I try to connect COM client
> to the server it starts a new copy of server EXE if I create object using
> CoClassCreator or get NULL interface trying
> to connect to running service by ActiveInstance method of TCOMIMyInterface
> object:
> ---------- code sample ----------
> TCOMIMyInterface itf;

> bool __fastcall TForm2::GetData()
> {
>        itf = CoMyClass::Create();
> ........
> // itf is OK, but it starts new EXE

> -------- another sample --------
> TCOMIMyInterface itf;

> bool __fastcall TForm2::GetData()
> {
>        itf .ActiveInstance( CLSID_MyClass );
> // get itf.intf == 0
> ----------------------------------
> Has this problem any solution?

Re:Creating NT service serving as COM server


Sorry Ian, but could You be more specific?

U?ytkownik "Ian Chodera" <ichod...@pansec.com> napisa3 w wiadomo?ci
news:941601$k464@bornews.inprise.com...

Quote
> You need to add the Key "LocalService" to your AppID registry key for your
> COM class. You also need to make the Class Factory a Singleton

> "???? e??" <Pivova...@Polyplastic.ru> wrote in message
> news:3a4338a0_1@dnews...
> > I need to create NT service wich retrieves some data from web site
> > periodicaly and stores it in database.
> > This was done without problems. Now I want to control the service
> parameters
> > and viewing retrived data snapshot.
> > I tried to include COM server in the service wich gains access to this
> data.
> > But when I try to connect COM client
> > to the server it starts a new copy of server EXE if I create object
using
> > CoClassCreator or get NULL interface trying
> > to connect to running service by ActiveInstance method of
TCOMIMyInterface
> > object:
> > ---------- code sample ----------
> > TCOMIMyInterface itf;

> > bool __fastcall TForm2::GetData()
> > {
> >        itf = CoMyClass::Create();
> > ........
> > // itf is OK, but it starts new EXE

> > -------- another sample --------
> > TCOMIMyInterface itf;

> > bool __fastcall TForm2::GetData()
> > {
> >        itf .ActiveInstance( CLSID_MyClass );
> > // get itf.intf == 0
> > ----------------------------------
> > Has this problem any solution?

Other Threads