Win32::API and Inline::C should be able to help out here. Here's an Inline::C demo (based on some C code I found in my msdn documentation):
use warnings; use Inline C => Config => LIBS => '-lSetupAPI', BUILD_NOISY => 1; use Inline C => <<'EOC'; #include <windows.h> #include <setupapi.h> #include <stdio.h> #include <devguid.h> #include <regstr.h> int wrap_SetupDiGetClassDevs() { HDEVINFO hDevInfo; // Create a HDEVINFO with all present devices. hDevInfo = SetupDiGetClassDevs(NULL, 0, // Enumerator 0, DIGCF_PRESENT | DIGCF_ALLCLASSES ); if (hDevInfo == INVALID_HANDLE_VALUE) croak("INVALID_HANDLE_VALUE returned"); return hDevInfo; } void wrap_SetupDiDestroyDeviceInfoList(int hDevInfo) { SetupDiDestroyDeviceInfoList(hDevInfo); } void foo(int hDevInfo) { INLINE_STACK_VARS; SP_DEVINFO_DATA DeviceInfoData; DWORD i, DataT, buffersize; LPTSTR buffer; // Enumerate through all devices in Set. DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); INLINE_STACK_RESET; for (i=0;SetupDiEnumDeviceInfo(hDevInfo,i, &DeviceInfoData);i++) { buffer = NULL; buffersize = 0; // // Call function with null to begin with, // then use the returned buffer size // to Alloc the buffer. Keep calling until // success or an unknown failure. // while (!SetupDiGetDeviceRegistryProperty( hDevInfo, &DeviceInfoData, SPDRP_DEVICEDESC, &DataT, (PBYTE)buffer, buffersize, &buffersize)) { if (GetLastError() == ERROR_INSUFFICIENT_BUFFER) { // Change the buffer size. if (buffer) LocalFree(buffer); buffer = LocalAlloc(LPTR,buffersize); } else croak("ERROR 1 in sub foo"); } INLINE_STACK_PUSH(sv_2mortal(newSVpv(buffer, 0))); if (buffer) LocalFree(buffer); } if ( GetLastError()!=NO_ERROR && GetLastError()!=ERROR_NO_MORE_ITEMS ) croak("ERROR 2 in sub foo"); INLINE_STACK_DONE; INLINE_STACK_RETURN(i); } EOC # perl code starts here: my $handle = wrap_SetupDiGetClassDevs(); my @devices = foo($handle); # clean up wrap_SetupDiDestroyDeviceInfoList($handle); print $_, "\n" for @devices;
Feel free to modify the code so that it does what you want. I don't think MinGW contains the requisite C header files, so you would need an MS compiler to run that code. And because the code passes a handle around, the compiler probably needs to be VC 6 (not VC 7 or 8) - assuming that your perl was built with VC 6.

So ... it may not be all that useful to you ... but it kept me occupied for a while :-)

Cheers,
Rob

In reply to Re: Generating a windows Device Interface Path in perl? by syphilis
in thread Generating a windows Device Interface Path in perl? SOLVED! by cmv

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.