I am sorry no one has replied to your question. To me it looks as if your code should work.
Unfortunately I have no experience of developing NT Service applications, however I make regular use of Shell_NotifyIcon API call to add an icon to the system tray. NIM_ADD is the correct call to add your icon to the system tray so I can not understand why it is not appearing.
You may want to check the obvious, and ensure that you are calling the same code in both debug mode and normal mode. Also check that your constants and the NOTIFYICONDATA type are declared correctly, they should be:
Code:
Const NIM_ADD = 0
Const NIM_MODIFY = 1
Const NIM_DELETE = 2
Const NIF_MESSAGE = 1
Const NIF_ICON = 2
Const NIF_TIP = 4
Const WM_MOUSEMOVE = 512
Type NOTIFYICONDATA
cbSize As Long
hWnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip(0 To 63) As Byte
End Type
Then check that all the handles are being assigned correctly, maybe you are using a different handle when running in normal mode that for some reason is not valid. If your handle to the icon is incorrect, or it is not an icon (perhaps it is a bmp) then a space will be allocated in the system tray for the icon, however it will not be displayed because nothing other than an icon will show up.
Also make sure you are setting the correct cbSize for your NOTIFYICONDATA, the best way to make sure of this is to set cbSize to:
Code:
nid.cbSize = Len(nid)
uFlags should be set NIF_MESSAGE Or NIF_ICON Or NIF_TIP and uCallbackMessage should be equal to WM_MOUSEMOVE. Other than that I am afraid I have run out of ideas.
Regards
Owain Williams