in reply to Win32::API getting a listing of available serial ports

This is one of those really awkward apis to locate, call and decode.

Upshot: This is what I got as far as it goes. It shows that I have successfully retrieved the data, but the mechanism for accessing it leaves much to be desired. This would probably be easier to do vis Inline::C.

HTH.

#! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'unicows', q[ BOOL EnumPortsW( LPTSTR pName, DWORD Level, LPBYTE pPorts, DWO +RD 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

Considered: BrowserUk: "Could be deleted." Vote was: Keep: 10, Edit: 0, Reap: 5.
Unconsidered: davido: Positive node rep and sufficient keep votes prevent reaping.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."