🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Services and Tray icon

#12838
From: Remy Lebeau (TeamB)
Date: Sun, 16 Nov 2003 00:23
43 lines
2922 bytes
"Boguslaw Fries" <B.Fries@luca-online.de> wrote in message
news:3fb6a058$1@newsgroups.borland.com...

> But now I have to use the same program as system service.

Services are background processes.  They should not be accessing the GUI,
which includes creating forms and displaying system tray icons.  Services do
not usually run in the same desktop/workstation as the logged in user, so
they have their own share of resources that are separate from the logged in
user's desktop.  As such, you should use a separate non-service application
that runs under the user's account session for any GUI work, and have the
app and service communicate back and forth via an IPC mechanism (named pipe,
RPC, COM, TCP/IP socket, etc) when needed.

With that said, it is possible to access the user's GUI from a service, but
it is more trouble than it is worth to do so.  You could mark the service as
being "Interactive" in the SCM (I do not know if SrvAny supports that), but
that has come consequences of its own if the service is not set up to handle
it correctly.  Otherwise, you can access the user's desktop manually as
described in the following article:

    Interacting with the User in a Service

http://msdn.microsoft.com/library/en-us/dllproc/base/interacting_with_the_user_in_a_service.asp

However, this last part can be tricky since services run before the user is
logged in and thus the GUI may not always be available.  Plus, the service
would have to track the user session so that if the user tries to log out,
the service can clean up after itself.

> but there is no Icon!!

Nor should there be.

> Shell_Notifyicon. return false.

Exactly.  There is no system tray for services when they run under their own
desktops, thus there is nothing for Shell_NotifyIcon() to work with
correctly.


Gambit
Technical Details
Message-ID: <3fb6c2a7$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3fb6a058$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,a6935d49d32b7b6d
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-15 16:37:35 PST
From: "Remy Lebeau \(TeamB\)" <gambit47.no.spam@no.spam.yahoo.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fb6a058$1@newsgroups.borland.com>
Subject: Re: Services and  Tray icon
Date: Sat, 15 Nov 2003 16:23:28 -0800
Lines: 45
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 67.22.137.149
Message-ID: <3fb6c2a7$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1068941991 67.22.137.149 (15 Nov 2003 16:19:51 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.media.kyoto-u.ac.jp!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed.freenet.de!216.166.71.118.MISMATCH!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail