Hi,

Very neat.  I found the icons in C:\WINDOWS\SYSTEM32\INETCPL.CPL' though.

Do you have pointers to more info on this API?  I am not really a 
windows programmer.

Thanks

Tom

daz wrote:
> Sung Soo Kim wrote:
> 
> 
>>How can I make my program appear in the system tray of the Windows?
>>
>>What I want my program do is to keep track of time regularly (using
>>timer) and do something behind the scene. (like a scheduler.)
>>So, I want to make my program disappear from main desktop and appear in the
>>system tray.
>>
>>What can I do?
> 
> 
> This puts a green tick in the SysTray, then changes it to a red minus
> (No Entry sign in UK), then removes it.  Delays in between (sleep).
> 
> I was going to send a traffic light sequence but I'm not certain whether
> it's using a generally available DLL.  I think most will have INETCPL.CPL
> 
> You can use any DLL that has icon(s), probably .EXE also ?
> 
> Have fun,
> 
> 
> daz
> 
> 
> #-------------------------------------------------------------------------------
> 
> require 'Win32API'
> 
> RT_ICON         =  3
> DIFFERENCE      = 11
> RT_GROUP_ICON   = RT_ICON + DIFFERENCE
> 
> NIF_MESSAGE = 1
> NIF_ICON    = 2
> NIF_TIP     = 4
> NIM_ADD     = 0
> NIM_MODIFY  = 1
> NIM_DELETE  = 2
> 
> 
> ExtractIcon       = Win32API.new('shell32',  'ExtractIcon',       'LPI',  'L')
> Shell_NotifyIcon  = Win32API.new('shell32',  'Shell_NotifyIconA', 'LP',   'I')
> 
> 
> hicoY = ExtractIcon.call(0, 'C:\WINDOWS\SYSTEM\INETCPL.CPL', 21)  # Green tick
> hicoN = ExtractIcon.call(0, 'C:\WINDOWS\SYSTEM\INETCPL.CPL', 22)  # Red minus
> 
> tiptxt = 'test icon (ruby)'
> pnid = [6*4+64, 0, 'ruby'.hash, NIF_ICON | NIF_TIP, 0, hicoY].pack('LLIIIL') <<
>        tiptxt << "\0"*(64 - tiptxt.size)
> ret = Shell_NotifyIcon.call(NIM_ADD, pnid)
> p 'Err: NIM_ADD' if ret == 0
> 
>       sleep(3)   #  <----<<
> 
> pnid = [6*4+64, 0, 'ruby'.hash, NIF_ICON | NIF_TIP, 0, hicoN].pack('LLIIIL') <<
>        tiptxt << "\0"*(64 - tiptxt.size)
> ret = Shell_NotifyIcon.call(NIM_MODIFY, pnid)
> p 'Err: NIM_MODIFY' if ret == 0
> 
>       sleep(6)   #  <----<<
> 
> pnid = [6*4+64, 0, 'ruby'.hash, 0, 0, 0].pack('LLIIIL') << "\0"
> ret = Shell_NotifyIcon.call(NIM_DELETE, pnid)
> p 'Err: NIM_DELETE' if ret == 0
> 
> #-------------------------------------------------------------------------------
> 
>