#! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'unicows', q[ BOOL EnumPortsW( LPTSTR pName, DWORD Level, LPBYTE pPorts, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned ) ], ) or die $^E; my $bytesNeeded = pack 'V', 0; my $portsRecvd = pack 'V', 0; my $buf = chr(0) x 2000; print '?',EnumPortsW( 0, 1, $buf, 2000, $bytesNeeded, $portsRecvd );# or print $^E; $bytesNeeded = unpack 'V', $bytesNeeded; $portsRecvd = unpack 'V', $portsRecvd; print "b:$bytesNeeded p:$portsRecvd"; my @pointers = unpack "V$portsRecvd", $buf; printf "%08x\n", $_ for @pointers; print unpack 'P12', $_ for unpack '(a4)10', $buf; __END__ C:\test>junk9 ?1 b:160 p:10 019190e6 019190da 019190ce 019190c2 019190b6 019190aa 0191909e 01919092 01919086 0191907c U S B 0 0 1 C O M 1 : C O M 2 : C O M 3 : C O M 4 : F I L E : L P T 1 : L P T 2 : L P T 3 : N U L : L