#!perl use Win32::Daemon; use Win32::GUI; my $id = "1"; $main = Win32::GUI::Window->new(-title => 'Backupi', -left => 100, -top => 100, -width => 150, -height => 100, -name => 'Main', -visible => 0 ); $icon = new Win32::GUI::Icon('server.ICO'); $ni = $main->AddNotifyIcon(-name => "systray", -id => $id, -icon => $icon, -tip => "Backupi"); Win32::Daemon::StartService(); while (SERVICE_START_PENDING != Win32::Daemon::State()) { sleep(1); } Win32::Daemon::State(SERVICE_RUNNING); while (1) { open FOUT, ">>c:\\win32testserv.log"; print FOUT localtime() . "\n"; close FOUT; sleep 3; if (Win32::Daemon::State() == SERVICE_STOP_PENDING) { open FOUT, ">>c:\\win32testserv.log"; print FOUT "Jetzt ist aber Schluss\n"; close FOUT; exit 0; } } Win32::Daemon::StopService(); Win32::Daemon::State(SERVICE_STOPPED); sub systray_RightClick { $systray_menu = new Win32::GUI::Menu( "SystrayMenu Functions" => "SystrayMenu", "> Starte den Dienst" => "AmphetaDesk::OS::Windows::_OpenBrowser", "> Stope den Dienst" => "AmphetaDesk::OS::Windows::_RefreshChannels", "> Exit" => "SystrayExit" ); my($x, $y) = Win32::GUI::GetCursorPos(); $main->TrackPopupMenu($systray_menu->{SystrayMenu}, $x, $y-50); } sub Main_Terminate { &exit_program; } sub SystrayExit_Click { &exit_program; } sub exit_program { Win32::GUI::NotifyIcon::Delete( $ni, -id => $id ); exit; }