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!


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."

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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.