Board index » delphi » Automation server in an NT service

Automation server in an NT service

Hi!

I have an NT service that is itself an automation server. Now I want to
attach to that running automation server on the same machine (from some
control application, that is). I tried to create an object from the
interface object in the TLB file, set connectkind to ckRunningInstance and
connect, but it keeps telling me there is no active object available
(although the service is running, of course). Any ideas, please?

Oliver

--
Oliver Sturm <O.St...@Manfred-Dahlhoff.de>

Fa. Manfred Dahlhoff - Buellenkothenweg 37a - 40229 Duesseldorf
Tel.: 0211-2202821   - Fax: 0211-2202822    - http://www.Manfred-Dahlhoff.de

 

Re:Automation server in an NT service


Oliver,
  here's a portion of my notes on this subject as to how to make this work:

1. Run DCOMCNFG.  Find the service object, and open its Properties page.
Click OK to close this page, then click OK to close DCOMCNFG.  This will
register the object under the AppID portion of the registry.
2. Run RegEdit and open up the key HKEY_CLASSES_ROOT/AppId.
3. Locate and select the GUID under AppId that matches the GUID in your
Service Application's Type Library.  (The "Default" key value there should
be something like the name of your DCOM object followed by the word "Object"
.)
4. Change the Default key value for this registry key to the Display Name of
your service.  (This is just so you see the sevice name, not the object
nema, in DCOMCNFG.)
5. Add a new String Value for this key.  Call it LocalService.  Make its
value the same as the Name property of your TService as seen in Delphi's
Object Inspector when you view the "form" for the service.  Close the
registry editor to save it.
6. Run DCOMCNFG again.  Select the object (which should now have the service
's full display name instead of the object name) and view its properties.
If everything was done right, the Identity tab should have the radio button
labeled "The System Account (services only)" selected.  If click on OK
(twice) to save the configuration settings.

HTH
-Howard

Re:Automation server in an NT service


Howard,

Thanks a lot for your help, makes me think I missed something ;) But it
still doesn't work... I've come to some conclusions since writing the first
message. I did the following:

I wrote a sample program (without the service) which is an automation
server. I gave it a property and a method to work with. I wrote a client for
the server which calls the automated method and accesses the property.
Everything is all right.

Something I don't know if I did right, I need to instantiate my COM object
in the server once and use RegisterActiveObject to make the client find it.
Otherwise the client will fork it's own server. Does that have to be this
way?

Now, when I start the server as administrator (I'm using Windows 2000), the
client won't find the running server anymore, so it launches it's own or
aborts when using ckRunningInstance.

When I start the server as a normal user and the client as administrator, it
seems to find the server running, but gives an error "access denied". So I
figured the problem would be permission related.

This example seems to be relevant for my problem with the service, so I
thought if I'd get this to work I might get closer to a working service. I
tried fiddling round with the settings in dcomcnfg a little, but to no
avail. I've read there is something like a registry for running OLE objects
somewhere, obviously this thing works on a per-user basis. How can I look
for an active object globally (on one system)?

Oliver

--
Oliver Sturm <O.St...@Manfred-Dahlhoff.de>

Fa. Manfred Dahlhoff - Buellenkothenweg 37a - 40229 Duesseldorf
Tel.: 0211-2202821   - Fax: 0211-2202822    - http://www.Manfred-Dahlhoff.de

Re:Automation server in an NT service


An NT COM service will run in its own window station (virtual desktop)
separate from, say, your Windows desktop window station. Each window station
has its own copy of the Running Object Table (ROT) which is where your
object goes when you call RegisterActiveObject, and the ROT is not
accessible across window stations. This explains your scenario.

have fun
--
Binh Ly
Need help on COM development?
http://www.techvanguards.com

Quote
Oliver Sturm <o.st...@manfred-dahlhoff.de> wrote in message

news:8alp3v$qqb13@bornews.borland.com...
Quote
> Hi!

> I have an NT service that is itself an automation server. Now I want to
> attach to that running automation server on the same machine (from some
> control application, that is). I tried to create an object from the
> interface object in the TLB file, set connectkind to ckRunningInstance and
> connect, but it keeps telling me there is no active object available
> (although the service is running, of course). Any ideas, please?

> Oliver

> --
> Oliver Sturm <O.St...@Manfred-Dahlhoff.de>

> Fa. Manfred Dahlhoff - Buellenkothenweg 37a - 40229 Duesseldorf
> Tel.: 0211-2202821   - Fax: 0211-2202822    -

http://www.Manfred-Dahlhoff.de

- Show quoted text -

Quote

Re:Automation server in an NT service


"Binh Ly" <b...@castle.net> schrieb im Newsbeitrag news:38d1b10f@dnews...

Quote
> An NT COM service will run in its own window station (virtual desktop)
> separate from, say, your Windows desktop window station. Each window
station
> has its own copy of the Running Object Table (ROT) which is where your
> object goes when you call RegisterActiveObject, and the ROT is not
> accessible across window stations. This explains your scenario.

Sounds like it ;) Well... What I thought I might do is the following:

I have an application running as a service, feeding a database with data
received from a lotus notes connection. Now I need to control that service
from an external application, show status information on the service, read
the logs, configure options and so on. This external application will be run
by several users with different permissions of what to see or what to
configure.

I thought it was a good idea to control the service using OLE automation,
first because that seemed like the state-of-the-art way to do this and
second, because I'll have a lot of options for integration in different
environments. If my customer wants to create serial letters in Winword from
his service log files, he can do so ;)

Obviously, it doesn't work this way. Does anyone have suggestions?

Oliver

--
Oliver Sturm / <st...@oliver-sturm.de>

Key ID: 71D86996
Fingerprint: 8085 5C52 60B8 EFBD DAD0  78B8 CE7F 38D7 71D8 6996

Re:Automation server in an NT service


Oliver Sturm skrev i meldingen <8atslu$3...@bornews.borland.com>...

Quote
>I have an application running as a service, feeding a database with data
>received from a lotus notes connection. Now I need to control that service
>from an external application, show status information on the service, read
>the logs, configure options and so on. This external application will be run
>by several users with different permissions of what to see or what to
>configure.

>I thought it was a good idea to control the service using OLE automation,
>first because that seemed like the state-of-the-art way to do this and
>second, because I'll have a lot of options for integration in different
>environments. If my customer wants to create serial letters in Winword from
>his service log files, he can do so ;)

>Obviously, it doesn't work this way. Does anyone have suggestions?

Well, you've allways got the good ol' Network protocols like TCP/IP or
whatever is used on your LAN. If you're on TCP/IP, you have the components
TServerSocket / TClientSocket in Delphi. It's a bit harder, especially if you
want a COM-interface on the client side, having to create both this and the
TCP/IP layer.
Additionally, you have Remote procedure Calls (RPC) and NetDDE...which I
don't know very well.

Well, just an idea...;-)

--
Bjoerge Saether
Consultant / Developer
Asker, Norway
bsaether.removet...@online.no (remove the obvious)

Other Threads