+: ensure-null-terminated ( str -- str' )
+ dup ?last 0 = [ "\0" append ] unless ; inline
+
+: add-tray-icon ( title -- )
+ NIM_ADD
+ NOTIFYICONDATA <struct>
+ NOTIFYICONDATA heap-size >>cbSize
+ NOTIFYICON_VERSION_4 over timeout-version>> uVersion<<
+ NIF_TIP NIF_ICON bitor >>uFlags
+ world get handle>> hWnd>> >>hWnd
+ f GetModuleHandle "APPICON" native-string>alien LoadIcon >>hIcon
+ rot ensure-null-terminated utf8 encode >>szTip
+ Shell_NotifyIcon win32-error=0/f ;
+
+: remove-tray-icon ( -- )
+ NIM_DELETE
+ NOTIFYICONDATA <struct>
+ NOTIFYICONDATA heap-size >>cbSize
+ world get handle>> hWnd>> >>hWnd
+ Shell_NotifyIcon win32-error=0/f ;
+