Bah humbug! I should really read the posts I reply to. Substituting 'winspool.drv' (as you mentioned) into my code in the other post, and using EnumPortsA gives:
Updated: Simplified last line of code. With thanks to util.
#! perl -slw use strict; use Win32::API::Prototype; ApiLink( 'Winspool.drv', q[ BOOL EnumPortsA( 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; EnumPortsA( 0, 1, $buf, 2000, $bytesNeeded, $portsRecvd ) or die $^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 'p', $_ for unpack "(a4)$portsRecvd", $buf; ## The above simplifies to (thanks [util]) print for unpack "(p)$portsRecvd", $buf; __END__ C:\test>junk9 USB001 COM1: COM2: COM3: COM4: FILE: LPT1: LPT2: LPT3: NUL:
Which I think is all that's required. If you need the extended information, then you'll need to work a bit harder.
I'll have to add the export lists of *.DRV (and probably some other extensions) to my big list!
In reply to Re: Win32::API getting a listing of available serial ports
by BrowserUk
in thread Win32::API getting a listing of available serial ports
by rpnoble
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |