Sorry for the delay...  I'm not sure if 3rd party DLLs are any different
than MS DLLs to Win32::API, assuming it's in your path...

But, here's an example of printing out midi device capabilities with
Win32::API and Winmm.dll (although, it's pretty straight-forward, once you
understand what data structures the DLLs functions are expecting...)

One hint:  For MS DLLs, hope to god you have a copy of VC on-hand.  The MSDN
documentation doesn't like to tell you what the CONST values are, and
everything uses them.  For example, Winmm.dll's constants can be found in
MMSYSTEM.H.

----code---
use strict;
use warnings;

use Win32::API;

my %devices = ();

 # two functions imported from Winmm.dll

my $midiOutGetNumDevs = Win32::API->new("Winmm","midiOutGetNumDevs",[],'I');
my $midiOutGetDevCaps =
Win32::API->new("Winmm","midiOutGetDevCaps",['I','P','I'],'N');

 # get # of midi out devices available.

my $num_devs = $midiOutGetNumDevs->Call();

if(!defined($num_devs) || $num_devs < 1) {
   print("No MIDI Devices Available on System\n");
   exit(0);
   }

 # the structure which device capabilities will be returned in is defined
 # as :
 # typedef struct tagMIDIOUTCAPSA {
 #    WORD    wMid;                  /* manufacturer ID */
 #    WORD    wPid;                  /* product ID */
 #    MMVERSION vDriverVersion;      /* version of the driver */
 #    CHAR    szPname[MAXPNAMELEN];  /* product name (NULL terminated
string) */
 #    WORD    wTechnology;           /* type of device */
 #    WORD    wVoices;               /* # of voices (internal synth only) */
 #    WORD    wNotes;                /* max # of notes (internal synth only)
*/
 #    WORD    wChannelMask;          /* channels used (internal synth only)
*/
 #    DWORD   dwSupport;             /* functionality supported by driver */
 # }
 #
 # So, WORD is defined as an unsigned short, DWORD an unsigned int,
MMVERSION is a DWORD
 # and CHAR is an asciz string, where MAXPNAMELEN is 32... So, we pack that
structure to be
 # passed as a pointer to midioutgetdevcaps...  We'll re-use it so we don't
have to pack it over
 # again.

my $midioutcaps_struct = pack('SSIZ32SSSSI',0,0,0,0,0,0,0,0,0);

 # get & store device info

foreach my $x (1..$num_devs) {
 my $dev_id = $x - 1;
 my $cap_struct = $midioutcaps_struct;

 my $return = $midiOutGetDevCaps->Call($dev_id,$cap_struct,5000);

 my @arr = unpack('SSIZ32SSSSI',$cap_struct);

 $devices{$dev_id} = ();
 $devices{$dev_id}{'manufacturer_id'} = $arr[0];
 $devices{$dev_id}{'product_id'} = $arr[1];
 $devices{$dev_id}{'drv_version'} = $arr[2];
 $devices{$dev_id}{'name'} = $arr[3];
 $devices{$dev_id}{'type'} = $arr[4];
 $devices{$dev_id}{'voices'} = $arr[5];
 $devices{$dev_id}{'notes'} = $arr[6];
 $devices{$dev_id}{'channels'} = $arr[7];
 $devices{$dev_id}{'support'} = $arr[8];

 }

print("Number of MIDI Out Devices On System: $num_devs\n");
print("Device Information:\n");

foreach my $device (keys(%devices)) {
 print("\nDevice $device :\n");
 foreach my $key (keys(%{ $devices{"$device"} })) {
  my $data = $devices{"$device"}{"$key"};
  print("\t$key:\t\t$data\n");
  }
 }

----end----

!c

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users

Reply via email to