#package client_reg; use vpcommon; #require Exporter; #@ISA = qw(Exporter); # Items to export into caller's namespace by default. #@EXPORT = qw(getClientListFromReg); use Win32::Registry; $DEBUG = 0; do ('sub_ErrorLog.pl'); %regKey_array=(); #global ################################################################### # sub createPair # Desc: pair up a key with a value and put them into an assiciative array # # ####################################################################### sub createPair{ my($key, $value) = @_ ; $regKey_array{$key} = $value; }; # end sub createPair ################################################################### # sub printPair # Desc: print the pair of a key with a value from an associative array # # ####################################################################### sub printPair{ #my($key, $value) = @_ ; while (($key, $value) = each %regKey_array) { print("$key, $value\n"); }; }; # end sub printPair ###################################################################### # # sub getClientListFromReg() # DEsc: return a list of clients name in string from regkey # defined in CONST_REG_KEY_CLIENTKEY in file LogUpdater_conf.conf # default return is "None" # # ####################################################################### sub getClientListFromReg { local ($targetRegKey)=@_; local(@clientList,%clientNamesHash,$reg_handle); my $handle; my $SubKeys; my $key; # open regkey hive $handle = $::HKEY_LOCAL_MACHINE->Open($targetRegKey, $SubKeys); die("Unable to open $targetRegKey") unless defined($SubKeys); # get a list of sub reg keys under hive, put them into an array $SubKeys->GetKeys(\@clientList); my $idx =0; my $position = 0; local ($s); # loop through each array element, chop the Guid out from client key # put the result into an associative array with key index foreach $key (@clientList) { $position = index($key,'_::'); $s = substr($key,0,$position); createPair($idx,$s); $idx = $idx+1; } if ($DEBUG) { printPair}; # close reg key hive $::HKEY_LOCAL_MACHINE->Close(); } # end getClientListFromReg #### do (client_reg.pl); $debug =0; ##### read in config file ############################## $SvcConfFile1 = 'LogUpdater_conf.conf'; open(IN,"<:utf8", "$SvcConfFile1") || print "Unable to open $SvcConfFile1"."\n"; while () { chop($_); eval $_; } ################################################ # populate the regkeyarray getClientListFromReg($SAVCLIENTKEY); print %regKey_array;