Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SvCom, NT Service, DCOM - 12 questions

106 views
Skip to first unread message

Martin Liesén

unread,
Apr 19, 1999, 3:00:00 AM4/19/99
to
Hello!

I have a lot of questions. If anyone have the time to answer one or some of
them it could help me a lot. I guess some of the is more or less directed to
Alexey Dynnikov.

I have an application which I must convert to a NT service, the service runs
on it's own without any interaction but the user can start a client
application which can show a whole lot of what is going on in the service
and also do quite a lot of configurations. I'm not at the moment very
interested in DCOM, as my application has it's own ways of communicating
between machines (but I guess I get it for free...?)

What I'm wondering about is if COM (DCOM) really is the way to go. That is
what the questions is about, finding some info so I can make a well thought
through decision between COM or some own protocol for Memory mapped files /
WinSock / Pipes or whatever...


1) Can I have events supporting multiple clients in a svCom service ?

2) Can the service use the system account when it contains a COM object ?

3) What if any limitations does svCom put to the implementation of
automation objects ?

4) Even if I take special steps in the service, is it possible that a user
can hang the service by some strange COM bug. (for example if the user kills
the client application process). It is very important that my service is
alive and well under any conditions as it handles critical alarm messages,
we do use backup systems through hardware to alert if the system fails, but
it's not something that we would like to see happen every once in a while as
it would seriously hurt our reputation.

5) I also must be able to run the COM server in a Windows 98 environment,
does this mean that I need a different executable for the different
operating systems, and is it "wise" to let them implement the same
automation objects with the same GUID:s.

6) Can I detect when a user is logged in ?

7) Can I receive a notification when a user login and logout ?

8) Is it safe to display information on the login desktop and when the user
log in, can I transfer the window to his desktop ?

9) If I'm using the system account, is there anyway I can access resources
like MAILSLOTS or remotely located files.

10) There is a lot of talk about impersonating users to get access to
resources. Is this only the case when I use the system account? (I can
easily force my users to make my service run as the administrator, but I
find it disturbing as it makes one more step for the user in the
installation phase.).

11) I've understood that only parts of the VCL is thread safe (memory
manager, but no graphic stuff). Is it safe to use the same non graphic class
in several threads as long as no object is shared in-between the threads ?
And if it is, is it still safe if I use runtime packages? (I'm thinking
about classes like TRegistry that probably isn't thread safe, should such a
object be made safe trough critical sections)

12) By just a strange coincidence - I made a service running in the system
account which launched a normal executable. If I lanced my own Delphi test
application it would be ready and show up when I logged in, and it was shut
down when I logged out. Just to get a notification that the application
actually was started before I logged in, I decided to launch winamp instead,
that's when the strange happened, it worked better than fine because winamp
never shutdown when I logged out. Is there anybody who can tell me how
winamp survived the logout ?


Thanks!
Martin Liesén, PegaSoft.

Alexey Dynnikov

unread,
Apr 19, 1999, 3:00:00 AM4/19/99
to
Hi, Martin !

Thank you for your questions. I'll try to answer all your questions.

Martin Liesén wrote in message <7fdr7r$qe...@forums.borland.com>...


>1) Can I have events supporting multiple clients in a svCom service ?

Yes. There is a SvCom tutorial on my homepage and the last example in it is
a link to the example written by Frazer Smith (Thanks again, Frazer !). This
example illustrates step-by-step how to implement support of events using
SvCom.

>2) Can the service use the system account when it contains a COM object ?

Sure. It is a standard NT feature. To ensure: start the DComCnfg utility and
go to the "Identity" page for any server. You will see that there is
radiobutton that allows to "Run as LocalSystem" (do not ermember the words
exactly). And it has a remark: "For services only!" It is this remark forsed
me to start services investigation.

>3) What if any limitations does svCom put to the implementation of
>automation objects ?

The limitations are common for services: it sould not show forms. Of course
it can show forms if it is interactive or performs some actions to access
user desktop but there are some problems with logoff/logon. This problems
are caused by VCL implementation, not SvCom features. Only one example: VCL
uses global atoms to get form from window handle. After logoff/logon the
global atom table is cleared. VCL does not takes care about it 8-(
No other limitations exist in comparison with regular Delphi-written DCOM
server. At least I do not know about it. If you will find any, let me know
and I'll do the best to remove it.

>4) Even if I take special steps in the service, is it possible that a user
>can hang the service by some strange COM bug. (for example if the user
kills
>the client application process). It is very important that my service is
>alive and well under any conditions as it handles critical alarm messages,
>we do use backup systems through hardware to alert if the system fails, but
>it's not something that we would like to see happen every once in a while
as
>it would seriously hurt our reputation.

If your service has no bugs and does not loads third-party dll's into its
address space you can be sure in its stability. Unfortunately it is
extremely difficult to guarantee that some application has no bugs. As for
SvCom implementation: I've not received any SvCom bug reports. If you know
bugs please let me know and I'll fix it as soon as possible (You are
absolutely right - the reputation is very important). In addition I use
SvCom in our project so I continue SvCom tests. All SvCom registered users
receives a sources so they can trace it as they wish to ensure that there
are no bugs in it. And of course I support registered users (and in many
cases not registered too) as it was decalred on my site.

>5) I also must be able to run the COM server in a Windows 98 environment,
>does this mean that I need a different executable for the different
>operating systems, and is it "wise" to let them implement the same
>automation objects with the same GUID:s.

Oops... I've read your previous question and answered it before this one. If
you think about stability then forget about servers on 95/98 systems. They
are too unstable. But if you insist...
At first there are no service on this systems. But it is not a problem for
SvCom! It was designed to be able to start as a regular executable. Version
1.2 supports this capability even for DCOM servers. I've introduced this
feature to simplify the debugging of services but as I see it it very useful
in some other situations. Another problem (not serious) exists: SvCom uses
static links to the Service API and EventLog Api functions. I guess that
this function are not available in 95 and (not sure) 98 systems. So attemt
to start SvCom application on such system should fail with message "entry
point ... not found in ..." or something like this. But it is easy to avoid
this problem. In any case it is a good idea, thanks, and I'll think about
it.

>6) Can I detect when a user is logged in ?
>7) Can I receive a notification when a user login and logout ?

Microsoft suggests a following way to detect interactive user logon: there
is a WinLogon key in registry and there is a Shell parameter in it. If the
application mentioned in this parameter runs then there is a logged on user.
Because MS does not suggest anything more I think there are no events or
hooks that could solve this problem.
Another indirect way is to check the HKEY_USERS subkeys. It contain .DEFAULT
subkey and SID's of all logged on users. But if there are services that work
in a specific account you will see corresponding SID's too. Another way is
to use some kind of notifier that is registered in Run key for example. It
will start at logon and notify service about it.
As for logout... It is easy. Build project as a console application and use
SetConsoleCtrlHandler to detect CTRL_LOGOFF_EVENT. Unfortunately I do not
know whether it works with all services or with interactive only (and can't
test it now - only 95 machine is available).

>8) Is it safe to display information on the login desktop and when the user
>log in, can I transfer the window to his desktop ?

I know only one way to show something on login desktop namely the
MessageBoxEx function with service_notification flag. It is safe.

>9) If I'm using the system account, is there anyway I can access resources
>like MAILSLOTS or remotely located files.

Sure. LogonUser + Impersonation allows to get any desired access. The LsaXXX
functions are suitable for storing private information such as necessary
passwords or login names. I've included several components that manages NT
security into SvCom. It is not published yet, I'm testing... I hope they
will be included into next SvCom release :-)

>10) There is a lot of talk about impersonating users to get access to
>resources. Is this only the case when I use the system account? (I can
>easily force my users to make my service run as the administrator, but I
>find it disturbing as it makes one more step for the user in the
>installation phase.).

Yes. If your service works under specific account and this account has
enough rights then you do not need in impersonation.
As for installation: you can cerate your own user at installation without
any prompts and configure its rights as you need. For example MS SQL does
so.

>11) I've understood that only parts of the VCL is thread safe (memory
>manager, but no graphic stuff). Is it safe to use the same non graphic
class
>in several threads as long as no object is shared in-between the threads ?
>And if it is, is it still safe if I use runtime packages? (I'm thinking
>about classes like TRegistry that probably isn't thread safe, should such a
>object be made safe trough critical sections)

This question should be answered separately in each specific situation. For
example stings are not thread-safe if you use one string variable across
threads but two variables that are used in its own threads are safe. The
same situation is with registry, data aware components, datamodules and so
on.

>12) By just a strange coincidence - I made a service running in the system
>account which launched a normal executable. If I lanced my own Delphi test
>application it would be ready and show up when I logged in, and it was shut
>down when I logged out. Just to get a notification that the application
>actually was started before I logged in, I decided to launch winamp
instead,
>that's when the strange happened, it worked better than fine because winamp
>never shutdown when I logged out. Is there anybody who can tell me how
>winamp survived the logout ?

Sorry, but I do not know what is 'winamp'. I know a small and popular MP3
player with the same name but it has no such features...
In common, if you ask about interactive services that survives logoff... In
theory to survive logoff application should close ALL its windows in
interactive desktop. It seems necessary and enough condition. But in
practice... I've played enough with it but due some problems with VCL the
success is not complete. The current maximum is: SvCom-written service that
correctly handles CTRL_LOGOFF_EVENT and re-registers all necessary atoms
after re-login is able to show a form with frame and caption. This form can
be resized and moved over desktop. Nothing more. No repaint, no events,
NOTHING. Just empty frame with caption. Now I know that the last event
successfully received by this form is WM_PAINT. After it form does dies
-( and I do not know why.

If you have other questions, feel free to contact with me

With kind regards,

Alexey Dynnikov <al...@chat.ru>
http://www.chat.ru/~aldyn/
ICQ #18267212


Frazer Smith

unread,
May 11, 1999, 3:00:00 AM5/11/99
to
>>11) I've understood that only parts of the VCL is thread safe (memory
>>manager, but no graphic stuff). Is it safe to use the same non graphic
>class
>>in several threads as long as no object is shared in-between the threads ?
>>And if it is, is it still safe if I use runtime packages? (I'm thinking
>>about classes like TRegistry that probably isn't thread safe, should such
a
>>object be made safe trough critical sections)
>This question should be answered separately in each specific situation. For
>example stings are not thread-safe if you use one string variable across
>threads but two variables that are used in its own threads are safe. The
>same situation is with registry, data aware components, datamodules and so
>on.

The SvCom application that I am currently working on needs to access
some database tables (read only). I am trying the following approach:

1. place database VCL components on SvCom NT Service form

2. create a global TCriticalSection

3. wrap all database accesses in Aquire/Release's.

Since my database tables are not large, I don't think that this should
cause too much of a performance problem - but I am a bit worried,
since only one thread gets the Critical section at one time and
all the others wait.

Can anyone think of a better way ? I am nervous of threads around
COM/DCOM and I really want to keep things simple.

Frazer Smith
pfs@<spamwhacker>sesqui.mtt.net

(remove the <spamwhacker> to email me

seanh...@my-dejanews.com

unread,
May 19, 1999, 3:00:00 AM5/19/99
to
In article <7ff27a$rt...@forums.borland.com>,
"Alexey Dynnikov" <al...@chat.ru> wrote:
-----------8<-------------

> Of course
> it can show forms if it is interactive or performs some actions to
access
> user desktop but there are some problems with logoff/logon. This
problems
> are caused by VCL implementation, not SvCom features. Only one
example: VCL
> uses global atoms to get form from window handle. After logoff/logon
the
> global atom table is cleared. VCL does not takes care about it 8-(
> No other limitations exist in comparison with regular Delphi-written
DCOM
> server.

-----------8<-------------

This seems to be the nearest thing that can possibly explain my
problem. That being, my DCOM server launches well on the server
machine under interactive user, but as soon as I switch it to "This
User" and launch it from a client, I can see the server exe in the
server machine's tasklist but the client app freezes, for about 30
seconds then returns with CO_E_SERVER_EXEC_FAILURE. Every other time
I've had this error, it has occured immediatly, not this time. I
thought that maybe since my server app has a main form (and one single-
use class) and launching it as "This User" requires a new window-
station which I'm guessing constitutes a login. Hence srewing the
Global Atom Table. How does one make a DCOM server in Delphi to run as
"This User" otherwise?

TIA

Sean

--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---

0 new messages