Works like a charm!

Thanks, I'll be sure to read up on these 2 functions shortly. :)

Larry

-----Original Message-----
From: Mark Dootson [mailto:[EMAIL PROTECTED] 
Sent: May 23, 2008 7:53 AM
To: Leblanc, Larry
Cc: perl-win32-users@listserv.ActiveState.com
Subject: Re: UInt32 cast as SInt32

Hi,

I think pack / unpack are your friend as in example below.

Regards

Mark

use Win32;
use Win32::OLE qw (in);

my $shares = Win32::OLE->GetObject('WinMgmts://.')->ExecQuery('select *
from Win32_Share');

foreach my $share (in $shares ) {
    print 'Name: ' . $share->Name . "\n";
    print 'Path: ' . $share->Path . "\n";
    
    my $stype = $share->Type;
    my $utype = unpack('L', pack('L', $stype));
    
    print "Signed   Type: $stype\n";
    print "Unsigned Type: $utype\n";
    print qq(------------------------------\n);
}



Leblanc, Larry wrote:
> G'day,
> 
>  
> 
> When attempting to retrieve an unsigned, integer (UInt32) value from 
> *winmgmts:\\.\root\cimv2\Win32_Share.Type* (i.e. WMI), Perl is
returning 
> incorrect values (ex.: -2147483648 when I should be getting 2147483648

> or -2147483645 instead of 2147483651).
> 
>  
> 
> This obviously has to do with Perl incorrectly casting the resulting 
> value as a signed integer (i.e. SInt32), instead of an unsigned
integer 
> (i.e. UInt32).  Is there a way to tell Perl to cast the variable as
UInt32?
> 
> _ _
> 
> The platform is Windows Server 2003 Standard Edition, SP2, running 
> ActivePerl v5.8.8.822.
> 
> _ _
> 
> Thanks,
> 
>  
> 
> Larry
> 
> 
>
------------------------------------------------------------------------
> 
> _______________________________________________
> Perl-Win32-Users mailing list
> Perl-Win32-Users@listserv.ActiveState.com
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


_______________________________________________
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to