[python-win32] Adding a notification icon from a service

Mark Hammond skippy.hammond at gmail.com
Fri May 18 03:20:02 CEST 2012


On 18/05/2012 9:00 AM, Alan Trick wrote:
> Hi,
>
> I have two smallish python modules, one which runs a service, and the
> other which puts a notification icon with a trivial menu on the
> windows panel (these modules are quite similar to existing examples in
> pywin32). Both of these modules work fine by themselves. However when
> I try to create the notification module from the service, I get
> troubles. I'm starting the service using
> win32serviceutil.HandleCommandLine, and it works fine in debug mode
> (as long as I'm running as Administrator), but when I try to start it,
> the notification code fails and it won't add the icon; and when I try
> to stop it, it wont' stop and just hangs.
>
> The main problem that I can identify right now is that my calls to
> win32gui.Shell_NotifyIcon fails. It raises a pywintypes.error(0,
> 'Shell_NotifyIcon', 'No error message is available'). Does anybody
> know what this means, or have any idea how to figure out what it
> means?

Services don't have access to the desktop which is there the 
notification bar lives.  The usual way to implement this is with 2 
processes - one for the service and one for the taskbar, and to 
implement some kind of RPC between them, such as a named pipe - one of 
the service samples uses a named pipe so that should get you started.

HTH,

Mark


More information about the python-win32 mailing list