windows service & interact with desktop?

Windows specific forum
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

windows service & interact with desktop?

Post by jassing »

I have a service that needs to appear in the system tray when someone logs in. Anyone know of a trick other than having a 2nd exe run at login?
IdeasVacuum
Always Here
Always Here
Posts: 6426
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: windows service & interact with desktop?

Post by IdeasVacuum »

Not the answer to your question, but related: http://www.purebasic.fr/english/viewtop ... 12&t=45057
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: windows service & interact with desktop?

Post by LuCiFeR[SD] »

Personally, I would use the FindWindow API.

just get it to check every so often that the Shell_Traywnd is there... if it is, add the tray Icon. If not, check again in 30 seconds or something.
jassing
Addict
Addict
Posts: 1885
Joined: Wed Feb 17, 2010 12:00 am

Re: windows service & interact with desktop?

Post by jassing »

LuCiFeR[SD] wrote:Personally, I would use the FindWindow API.

just get it to check every so often that the Shell_Traywnd is there... if it is, add the tray Icon. If not, check again in 30 seconds or something.
Ah.. So if the service is running under a system account, if administrator logs in, it will be able to interact with that users desktop?

Interesting idea worth check into..
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: windows service & interact with desktop?

Post by LuCiFeR[SD] »

as the administrator, you are in charge of what users get access to whatever program. nothing to stop you checking what level of access a logged in user has and acting accordingly :) It won't do it by magic thats for sure hehe
LuCiFeR[SD]
666
666
Posts: 1033
Joined: Mon Sep 01, 2003 2:33 pm

Re: windows service & interact with desktop?

Post by LuCiFeR[SD] »

Actually, let me expand upon this a little... :) This is just to give you a rough idea of what I mean...

Code: Select all

Procedure.i FindTaskBar()
  If FindWindow_("Shell_TrayWnd",0)
    
    If OpenLibrary(0,"shell32.dll")      
      *MAlloc = GetFunction(0, "IsUserAnAdmin")
      
      If CallCFunctionFast(*MAlloc) = 1      
        Debug "Current user is Administrator"
        ;- Add code to add tray etc here
        
      Else    
        
        Debug "Current user is not an Administrator"
        ;- Decide what to do here if the user is not an administrator
      EndIf 
      
      CloseLibrary(0)
    EndIf 
    
  EndIf

EndProcedure
Post Reply