PDA

Click to See Complete Forum and Search --> : Icon in system tray


Raver
Dec 11th, 2001, 12:05 PM
Is there a way to find out if the icon that I placed in the system tray via an API call is still there?

If not

Is there a way to find out if the system tray is there?

Hack
Dec 11th, 2001, 01:36 PM
An icon in the system tray represents a running application. All you would need to do is check to see if that application was, in fact, running.

I don't understand, however, what you mean by thisIs there a way to find out if the system tray is there?

Raver
Dec 11th, 2001, 05:16 PM
I've actually been looking in these forums for quite some time now without any luck for my problem.

I'm trying to run an application as a service.

I've already got an icon to display in the system tray.
I've done that 3 step process (with instsrv.exe and srvany.exe) to add the application in the registry, blah blah blah.

Since I've been testing extensively, I'm getting 2 major results that are pretty close to my needs, except for some few problems.

First one is running the service without giving it permission to access the desktop (services applet). The application RUNS (without its interface - But I know its running cause of a log file) but there is no Icon that appears in the system tray and no way to access the interface. Therefore my previous question...

Second, is running the service with access to the desktiop, but this is creating an instance in the task manager's applications, which I don't belief is wanted. I only want it there if the form is shown.
Nevertheless, the service starts before user login. The problem is when the user logs out the application's status becomes NOT RESPONDNIG, I guess that windows is sending messages to all the applications that are running and kills them.

Since my application is running as a service why is it being killed?
Does it have anything to do with the fact that it has a form?
Is it because of the way it is compiled (Standard exe) ?

I've been looking for a solution on and off for about 2 weeks now without any luck.:confused: :confused: :confused: :confused:

Thankx in advance.

Raver
Dec 12th, 2001, 04:52 PM
To whom this might interest....

I finally resolved my problem and here is some information to whoever encounters the same problem:

As far as I know Windows will send a message to all opened applications and ask them to close up.

From my testing I got to the conclusion that my form is going through the Form_Unload event when the user logs off.

In this event I has some clean up code, then END. Well apparently the END is what was crashing the service. I just figured that since the form is being unloaded anyways there wouldn't be a difference if I also ended the application there, since my application can't run without it. (I tryed to unload the form by code and the application does crash (this is without the END in the event)).

So how can Windows make my form go through its Form_Unload event without crashing the whole thing? To my knowledge if a form unloaded all its procedures, Properties and events are not accessible unless the form is reloaded. I think I am more comfused than ever... If I missed something could someone please explain.

yg1491
Jan 15th, 2002, 06:46 AM
I am not sure if you are still woking on the project but maybe this can shed some light, When you logoff windows kills the system tray so if you were to have a system tray icon it would be gone but your app if its a service would still run. when the user logs back in the system tray is recreated by windows and your app would have to get this info and readd its icon to the sytem tray. I had this problem but resolved it.

Raver
Jan 15th, 2002, 04:30 PM
Actually no I'm done with that project, but thankx anyways for the info.

You are right about the system tray no longer existing on user logoff. In fact it all depends on how your service is configured in the services applet.

If its running under the system account you can allow it to interact with the deskop. (There are annoying limitation with this option: The one I experienced is known, but very frustrating. The system account can not access the printers. So since my service needed to use a printer driver I could not use this option)

But if you run it under a user's account then it will not be able to access the system tray or even display a form. Yes, it will run, but without an interface. If you have nothing to display, that's fine, but how is the user supposed to interat with the service. Correct me if I'm wrong ,but you can't even display an icon in the system tray. The user can only start and stop it from the services applet?? That's crappy.