🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #7892

Re: Controlling Windows service

#7892
From: Deepak Mishra
Date: Mon, 13 Dec 2004 13:29
64 lines
3568 bytes
Let me clarify some points,

1) It is a client-server application. Having multiple users connecting from different PCs to the Server.


>> Now the requirement is such that this process should be triggered
>> whenever the first user logs in to the system and should stop when
>> the last user logs out of the system.

2) By logging on to the system, I mean logging on to the application server, through presentation layer( Not logiing on to the Windows OS).

>Your service will need to register itself with the OS to receive user login
>events.  The problem is, if you use Borland's TService framework, you will
>not be able to do that.

3)Is there no method through which we can register services developed in BCB using Tservice framework.

4) The user login-logout events and number of logged-in user  we can handle through database server or "Server Application".

> You will have to write the service code completely
>from scratch so that you can call the additional API functions that are
>required which TService does not natively call - specially
>RegisterServiceCtrlHandlerEx(), having the callback function look for
>SERVICE_CONTROL_SESSIONCHANGE notifications.
>
>I should mention, however, that this only works for WinXP and newer OSes.
>For versions prior to XP, the only way to detect user logins/logouts are to
>either:
>
>1) write your own GINA.DLL to replace the native one.  GINA.DLL is the file
>that receives CTRL-ALT-DEL requests and controls the WinLogon screen.
>
>2) have the service continously poll for the current logged in user.
>Enumerate the active processes looking for Explorer.exe, and then query the
>user creditials from it via OpenProcessToken(), GetTokenInformation(), and
>LookupAccountSid().
>
>> Also, there should be some mechanism by which the end-user can
>> control this process. That is, the client application should also have
>> a button for initiating and terminating the process
>
>Just start and stop the service like any other service.  Look at the
>StartService() and ControlService() functions.
>
>> Now my concern is when the process is triggered automatically,
>> then the client application will neither have the "PID" nor the
>> "Process Handle".
>
>It does not need that information in the first place.
>
>> In such a scenario, can that process be terminated by its process name?
>
>Just stop the service.  Look at the ControlService() function.
>
>> Also, can we check the status of a process by its name so that we can
>> restrict the user from running multiple instances of the same process?
>
>Services do not allow multiple instances to begin with.
>
>
>Gambit
>
>
Technical Details
Message-ID: <41bd993f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <41bd5410$1@newsgroups.borland.com> <41bd87dc$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2580bf3649196f02
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Deepak Mishra" <deepak.dmishra@gmail.com>
Sender: "Deepak Mishra" <deepak.dmishra@gmail.com>
Reply-To: "Deepak Mishra" <deepak.dmishra@gmail.com>
Subject: Re: Controlling Windows service
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 203.200.198.98     
References: <41bd5410$1@newsgroups.borland.com> <41bd87dc$1@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.66
Message-ID: <41bd993f$1@newsgroups.borland.com>
Date: 13 Dec 2004 05:29:35 -0800
X-Trace: newsgroups.borland.com 1102944575 207.105.83.66 (13 Dec 2004 05:29:35 -0800)
Lines: 65
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!proxad.net!gatel-ffm!gatel-ffm!194.25.134.126.MISMATCH!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail