Hello,

I am trying to ececute next code with module WIN32::OLE:


$sec_tbl=Win32::OLE->new('TEClient.SlotTable') or die "oops: $!\n";
$sec_tbl->Open($obj->ID,"SECURITIES") or warn "unable to open table 
SECURITES!\n";
Win32::OLE->WithEvents($sec_tbl, \&table_events);


sub table_events
{
   my ($obj,$event,@args) = @_;
        print "Event triggered for: '$event'\n";
}


But it throws the exception:


Win32::OLE(*0*.*1709*) error 0x80004002: "No such interface supported"
Even i do


Win32::OLE->WithEvents($all_tbl, \&table_events,'_ISlotTableEvents');

it throws other exception:


error 0x80070057: 'The parameter is incorrect'


But when work with another object, thats ok:

my $sl = Win32::OLE->new('TEClient.Slot') or die "oops: $!\n";

Win32::OLE->WithEvents($sl, \&slot_events);


Name of interface i took from documentation for current object. What did i do wrong? Is this module's feature? Can you help me?


p.s. full code is attached.

--
Best regards, Maksim.
package tbl_event_handler;

sub AddRow {
        print "AddRow!!\n";
}

package main;
use locale;
use strict;
#use Win32::OLE;
use Win32::OLE qw(EVENTS);
use Data::Dumper;


my ($msg,$connect);
my ($all_tbl,$sec_tbl,$tr_tbl,$hdl_tbl);
$|=1;

Win32::OLE->Option(Warn => 3, _Unique => 1);
#Win32::OLE->Initialize(Win32::OLE::COINIT_MULTITHREADED);

my $sl = Win32::OLE->new('TEClient.Slot') or die "oops: $!\n";
Win32::OLE->WithEvents($sl, \&slot_events);



print "SlotID=",$sl->ID."\n";

#print "\n",Data::Dumper->Dump([ $sl ]);

# Slot connecting
print "Slot is connecting...";
my $open=$sl->Open($sl->ID);
$connect=$sl->Connect('213.181.12.52:7800','forts668','gfhjkm',\$msg);
if(Win32::OLE->LastError)
{
        die "error: ".Win32::OLE->LastError.'\n';
}
my $state=$sl->GetCurrentState();
print "Slot's state=$state\n";


# Main cycle
Win32::OLE->MessageLoop;


# Subs
sub slot_events
{
    my ($obj,$event,@args) = @_;
        if ($event eq 'Connected')
        {
                print "Slot ".$obj->ID." is connected\n";
        }
        elsif($event eq 'Synchronized')
        {
                # Òàáëèöà âñåõ ñäåëîê
                #$obj->ActivateTable($obj->ID,"ALL_TRADES") or warn "unable to 
open table ALL_TRADES!\n";
                $all_tbl=Win32::OLE->new('TEClient.SlotTable') or die "oops: 
$!\n";
                Win32::OLE->WithEvents($all_tbl, \&tbl_events, 
"_ISlotTableEvents");
                $all_tbl->Open($obj->ID,"ALL_TRADES") or warn "unable to open 
table ALL_TRADES!\n";             
                                
                print "\nLoading tables...done\n";
        }
        elsif($event eq 'Error')
        {
                warn "Error ",$args[2]," in slot ",$args[0],". Code 
",$args[1],"\n";
        }
        elsif($event eq 'Disconnected')
        {
                die "End script\n";
        }
        else
        {
                print "Event triggered for: '$event'\n";
        }
        
    #print "Event triggered for: '$Event'\n";
}

sub tbl_events
{
    my ($obj,$event,@args) = @_;
        print "Table event triggered for: '$event'\n";
}
_______________________________________________
Perl-Win32-Admin mailing list
Perl-Win32-Admin@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to