Accessing the USB port works OK. However when there are more than 1 - the usual case since the included Microsoft Synthesizer also responds to MIDI commands, I would like the program to determine the correct one to use. I have tried using the routines below to access the device names and actually got the names once but the program crashed. I don't understand how to use these functions to get the device name (probably in szPname). I have been unable to repeat the one success in a test program
for (midiport=0; midiport<3; midiport++;)
{
This works OK and the flag1 shows that the midiport number used is good or not. The device handle is useful:
// midiOutOpen(LPHMIDIOUT phmo, UINT uDeviceID, DWORD dwCallback, DWORD dwInstance, DWORD fdwOpen);
flag1 = midiOutOpen(&device, midiport, 0, 0, CALLBACK_NULL);
printf("flag1=%d device=%8x ", flag1, device);
Seems like this one should work since it says GetId in the name but it doesn't return anything useful so far:
// midiOutGetID(HMIDIOUT hmo, LPUINT puDeviceID);
flag2 = midiOutGetID(&hmo, midiport);
printf("flag2=%d hmo=%8x ", flag2, hmo);
This routine does pass a structure that contains szPname and I was able to get the name once but not reliably
I chose this routing only because the structure contained szPname:
// waveOutGetDevCaps(UINT uDeviceID, LPWAVEOUTCAPS pwoc, UINT cbwoc);
flag3 = waveOutGetDevCaps(midiport, &pwoc, cbwoc);
printf("flag3=%d pwoc=%8x pwoc->szPname=%s \n", flag3, pwoc, pwoc->szPname);
}
I have no documentation on these routines. I have just looked through the mmsystem.h file to find possibilities.
Can you help me understand how to extract the product name or other unique ID?
Regards, Richardd