I try to get a Win32 service running using the Activestate PDK. The 
problem is that I would like to initialize a variable during the Install 
method and use it later in the Startup method. The code below, however, is 
not working as expected.

If run interactively all is fine (the executable is named st):

> st
Some items can be configured via the gaga file

and the Eventlog shows the correct "The winner is gaga". 
If I install and start the service (works fine) I find "The winner is: Hu"
in the Eventlog instead. What I am doing wrong here ?

Thanks for any help,
Ekkehard

PS: I am using PDK 5.2.0 Build 520 and Perl 5.6.1 Build 635

----

package PerlSvc;

use strict;
use warnings;
use English;

our %Config = (ServiceName => "TestSvc",
               DisplayName => "A Test Service");

my %Globals = (configFile => 'Hu');

sub Install {
    $Globals{configFile} = "gaga";
}

sub Help {
    print "Some items can be configured via the $Globals{configFile} 
file\n";
}

sub Interactive {
    Install();
    Help();
    Startup();
}

sub Startup {
    require Win32::EventLog;

    my $EventType = Win32::EventLog::EVENTLOG_INFORMATION_TYPE();
    my $EventLog = Win32::EventLog->new("PerlMsg", "");
    $EventLog->Report({
        EventType => $EventType,
        Category  => undef,
        EventID   => 0xC0000004,
        Strings   => "The winner is: $Globals{configFile}",
        Data      => "",
    });
    while(ContinueRun()){sleep 1;}
}


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to