473,466 Members | 1,298 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

System Tray Application

Jay
Hey There,
I have a system tray application that is running, and it needs to
communicate with a Windows Service that I wrote. My problem is that if
a user switches to another desktop, I need the service to have
communication be able to distinguish that data needs to be sent to app
A instead of app B. I was going to try to use a desktop handle to
distinguish between the two, but I can't create the service as an
interactive service (nor would I want to, with it being a security
flaw, and also with Windows explicitly not allowing it in Vista). So,
if I have data that needs to be sent to one system tray app, how can I
differentiate between the two?

Thanks!
Jay
(patelj27b at gmail dot com)

Oct 31 '06 #1
11 1955
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
I have a system tray application that is running, and it needs to
communicate with a Windows Service that I wrote. My problem is that if
a user switches to another desktop, I need the service to have
communication be able to distinguish that data needs to be sent to app
A instead of app B. I was going to try to use a desktop handle to
distinguish between the two, but I can't create the service as an
interactive service (nor would I want to, with it being a security
flaw, and also with Windows explicitly not allowing it in Vista). So,
if I have data that needs to be sent to one system tray app, how can I
differentiate between the two?
I'm not sure what the problem is. Can't you have the service expose a socket
or a named-pipe interface to its clients? You can tag the messages that you
send over the socket or pipe with whatever identifying information you need.

Regards,
Will
Oct 31 '06 #2
Jay

William DePalo [MVP VC++] wrote:
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
I have a system tray application that is running, and it needs to
communicate with a Windows Service that I wrote. My problem is that if
a user switches to another desktop, I need the service to have
communication be able to distinguish that data needs to be sent to app
A instead of app B. I was going to try to use a desktop handle to
distinguish between the two, but I can't create the service as an
interactive service (nor would I want to, with it being a security
flaw, and also with Windows explicitly not allowing it in Vista). So,
if I have data that needs to be sent to one system tray app, how can I
differentiate between the two?

I'm not sure what the problem is. Can't you have the service expose a socket
or a named-pipe interface to its clients? You can tag the messages that you
send over the socket or pipe with whatever identifying information you need.

Regards,
Will
If the service needs to do some desktop interaction through the system
tray application, then it needs to know which one to do it on. the
originating message doesn't have information regarding which system
tray application to send it to. That conjunction information will be
kept in custom structures.

Thanks!
Jay
(patelj27b at gmail dot com)

Oct 31 '06 #3
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
If the service needs to do some desktop interaction through the system
tray application, then it needs to know which one to do it on.
Services should not interact with the desktop. That's the issue. AFAIK,
Vista will no longer support interactive services. IMO, now is a good time
to change your design.

Regards,
Will
Oct 31 '06 #4
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hey There,
I have a system tray application that is running, and it needs to
communicate with a Windows Service that I wrote. My problem is that if
a user switches to another desktop, I need the service to have
communication be able to distinguish that data needs to be sent to app
A instead of app B. I was going to try to use a desktop handle to
distinguish between the two, but I can't create the service as an
interactive service (nor would I want to, with it being a security
flaw, and also with Windows explicitly not allowing it in Vista). So,
if I have data that needs to be sent to one system tray app, how can I
differentiate between the two?
I think you're missing Will's point. You server should expose an RPC
interface - through sockets, named pipes, etc. Your system tray application
should connect to your server through that API when it's started and
disconnect from your server when the desktop is shut down (user logs out).
If multiple desktops are active (e.g. fast user switching, terminal
services), then you will have multiple copies of your client application
running and your server can send information to all of them, or use any
information at it's disposal to decide which client to send to.

Ultimately, the client is in a better position to decide whether it's
appropriate for it to receive information, since it has direct access to
it's own desktop and can easily discover when that desktop becomes inactive
or is destroyed. The server should simply do what it's told - returning
information to whichever client(s) ask for it.

Remember - think in terms of the client ASKing for information, not the
server SENDing information.

-cd
Nov 1 '06 #5

"William DePalo [MVP VC++]" <wi***********@mvps.orgwrote in message
news:Ou**************@TK2MSFTNGP05.phx.gbl...
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m73g2000cwd.googlegr oups.com...
>If the service needs to do some desktop interaction through the system
tray application, then it needs to know which one to do it on.

Services should not interact with the desktop. That's the issue. AFAIK,
Vista will no longer support interactive services. IMO, now is a good time
to change your design.
I believe "through the system tray application" running in the logged-in
user's context, IS the right way. It's only services that try to create UI
windows within the service process that need to be changed. Or no?
Regards,
Will

Nov 1 '06 #6
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
I believe "through the system tray application" running in the logged-in
user's context, IS the right way.
Yes, of course.

There's not a lot special about a tray application apart from the fact that
it is the shell displaying an icon in its client area for some other quite
ordinary application. Ordinary appplications are free to paint their UIs as
they like.
It's only services that try to create UI windows within the service
process that need to be changed. Or no?
Yes. Which is why I told the OP not to have his service interact with the
desktop (Vista will burn him in a couple of months).

The canonical approach is to have the service interact via some IPC
mechanism -with a non-service application which interacts with the desktop.

Regards,
Will
Nov 1 '06 #7
Jay

Carl Daniel [VC++ MVP] wrote:
"Jay" <pa*******@gmail.comwrote in message
news:11**********************@m7g2000cwm.googlegro ups.com...
Hey There,
I have a system tray application that is running, and it needs to
communicate with a Windows Service that I wrote. My problem is that if
a user switches to another desktop, I need the service to have
communication be able to distinguish that data needs to be sent to app
A instead of app B. I was going to try to use a desktop handle to
distinguish between the two, but I can't create the service as an
interactive service (nor would I want to, with it being a security
flaw, and also with Windows explicitly not allowing it in Vista). So,
if I have data that needs to be sent to one system tray app, how can I
differentiate between the two?

I think you're missing Will's point. You server should expose an RPC
interface - through sockets, named pipes, etc. Your system tray application
should connect to your server through that API when it's started and
disconnect from your server when the desktop is shut down (user logs out).
If multiple desktops are active (e.g. fast user switching, terminal
services), then you will have multiple copies of your client application
running and your server can send information to all of them, or use any
information at it's disposal to decide which client to send to.

Ultimately, the client is in a better position to decide whether it's
appropriate for it to receive information, since it has direct access to
it's own desktop and can easily discover when that desktop becomes inactive
or is destroyed. The server should simply do what it's told - returning
information to whichever client(s) ask for it.

Remember - think in terms of the client ASKing for information, not the
server SENDing information.

-cd
Thanks for all your help,
The situation above is what I have. I don't want to just blindly
send the message to all copies of the application. The service should
be able to know which one it is meant for and send it to that one. And
I am using sockets to send and receive data between the service and the
helper application. The purpose of the helper application is to do
whatever desktop interactions the service needs done.

-Jay
(patelj27b at gmail dot com)

Nov 1 '06 #8
>It's only services that try to create UI windows within the service
>process that need to be changed. Or no?

Yes. Which is why I told the OP not to have his service interact with the
desktop (Vista will burn him in a couple of months).

The canonical approach is to have the service interact via some IPC
mechanism -with a non-service application which interacts with the
desktop.
But you're preaching to the choir (the OP started out "I have a system tray
application that is running, and it needs to communicate with a Windows
Service that I wrote") and confusing the issue at the same time. Of course
a service should interact with a user, there are a variety of ways of doing
that, with varying levels of security. Having the service create a UI
window in-process is bad. Having the service delegate that UI window to a
separate app running in the user's security context, can be good, but
security checks are still needed, whether via named pipe ACLs, or
application-layer checks. Now the OP has run into the problem that there
can be multiple instances of this "separate app running in the user's
security context", whether via Remote Desktop/Fast User Switching (only one
user) or Terminal Services (concurrent users) and is looking for a way to
decide which instance to send prompts and notifications.
Regards,
Will

Nov 1 '06 #9
>
Thanks for all your help,
The situation above is what I have. I don't want to just blindly
send the message to all copies of the application. The service should
be able to know which one it is meant for and send it to that one. And
I am using sockets to send and receive data between the service and the
helper application. The purpose of the helper application is to do
whatever desktop interactions the service needs done.
Is the message a response to a helper application request, or a notification
triggered by something else in the system (disk attached, virus found, etc)?
-Jay
(patelj27b at gmail dot com)

Nov 1 '06 #10
"Ben Voigt" <rb*@nospam.nospamwrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
Now the OP has run into the problem that there can be multiple instances
of this "separate app running in the user's security context", whether via
Remote Desktop/Fast User Switching (only one user) or Terminal Services
(concurrent users) and is looking for a way to decide which instance to
send prompts and notifications.
So? The pipes and sockets that I suggested work well in a many-to-one
environment.

It's client server 101. He can have each client register the location or
means of a call back with the service. At the proper time the service
"calls" or "messages" the client. The client does the UI. Voila.

I think his issue (and I could be wrong as he didn't offer a lot in the way
of detail) - is that his service is making a (perhaps implicit) assumption
that client and service are on the same desktop. If not, why would the
user's desktop switching be a problem for him?

The Shatter Attack is a big enough deal and Vista's change is significant
enough that, IMO though YMMV, that it is worth pointing out to the OP and
anyone else reading my post that a service should not run on an interactive
desktop.

Regards,
Will
Nov 1 '06 #11
Jay

Ben Voigt wrote:

Thanks for all your help,
The situation above is what I have. I don't want to just blindly
send the message to all copies of the application. The service should
be able to know which one it is meant for and send it to that one. And
I am using sockets to send and receive data between the service and the
helper application. The purpose of the helper application is to do
whatever desktop interactions the service needs done.

Is the message a response to a helper application request, or a notification
triggered by something else in the system (disk attached, virus found, etc)?
-Jay
(patelj27b at gmail dot com)
Actually, some other application will send a message to the service,
and the service will need to send the information to the proper helper
application running. The service has interaction with other
applications which will sometimes need to direct information to the
helper application. It isn't just a one-to-one interaction. If I were
to have an array of sockets, each one connected to a specific helper
application, I would need to know that when a certain message is
received from another application, it needs to be directed to a
specific helper application.

-Jay

Nov 1 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: balu | last post by:
Hello , I Had a problem in developing a application for getting a message over or above system tray . When we first logon into the yahoo messenger , whenever a new user logon ,The messenger...
3
by: Nicolas Poirier | last post by:
I successfully made a system tray application. When I do shut down the computer, how does the computer can instruct my application to shut down? For the moment, if I don't quit my application,...
4
by: Tom | last post by:
Hello, System tray icon informs users that the apps is running in the background. However, there are instances that the app might crash and after that the app icon in the system tray is still...
10
by: Crouchie1998 | last post by:
Hello To All You Real Programmers Out There!! There is an application called: "Tray It" Webpage: ---------- http://www.teamcti.com/trayit/trayit.htm Direct Download:
5
by: scottt | last post by:
I asked a question along a similar line about a week ago and didn't get any replies. Let me try to ask the quetion again a little bit different to see if I can get some help on this problem. Is...
3
by: =?Utf-8?B?QXNhZg==?= | last post by:
Hi, I have created a System Tray application using C# for .NET 2.0. My PC will not shut down or make a restart if my System Tray application is working at the Tray. Only after I end the process...
3
by: Patrick Dugan | last post by:
I am using VS2005 (vb) and I have a program that starts when Windows boots up. Occasionally the icon that should appear in the system tray does not show up. The program is still running in memory...
3
by: Usman Jamil | last post by:
Hi I've a windows application that does a lengthy backup process. While the process is going on, I need to show a progress bar inside system tray or just above the system tray. Can someone...
22
by: rottmanj | last post by:
I am working on an app that I need to minimize/close to the system tray. More or less I have the minimize to the system tray working, save caveat. When it is minimized the application still...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.