• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 449
  • Last Modified:

programming mmsystem MCI_open (CD) / Wavein

1. opening CDAudio with MCI_OPEN
How can I get access to a specific CD-drive with mmsystem.dll´s commands ? I tried to realize it by MCI_open with MCI_open_element with lpstrelement='[Driveletter]:\track01.cda'
This works fine with win98, win95 refuses to open CDaudio-driver, posting MCIerror 296 (cannot open file with this mci-device or file corrupt.
Does Win95 not accept CDAudio as a compound device ?
Does anybody know how to get access to a specific CD-rom drive for CDAudio-services with mci-commands ?

2. WAVEINCLOSE
Openening the wavein-device via WAVEINOPEN(....) everything works fine. All WAVEIN-commands work fine except WAVEINCLOSE ! Trying to close the waveindevice I get the error message, that the given device ID is invalid although I use the Waveinhandle I received when opening the device with WAVEINOPEN.
What did I do wrong ?
How can I close the Waveindevice after opening it with WAVEINOPEN ?
THANKS
0
vader1
Asked:
vader1
  • 3
  • 2
1 Solution
 
chensuCommented:
1. How to Address Multiple CDAudio Devices in Windows NT
http://support.microsoft.com/support/kb/articles/q137/5/79.asp

2. waveInClose expects the handle of the waveform-audio input device instead of the device ID. Make sure the value of the handle is not changed. You may use waveInGetID to get the device ID to test if the handle is valid.
0
 
vader1Author Commented:
question one: thank you, perfect !!!
It´s so simple, I wonder why I didn´t find out myself !?
I always tried 'D:\track01.cda' as lpstrelement...

question 2 might have been a bit misleading:

Let me try to be more precise:
I tried to open then waveindevice via:

> waveInOpen(@myWaveIn,I, @mypcmformat,caller^.hwindow,callerInstance,CALLBACK_WINDOW );

while I is goes from 0 to waveInGetNumDevs-1
and the wanted ID is selected by waveingetdevicecaps and the wanted format.
waveingetdevicecaps reports that device ID 0 is able to support my format.
The selected waveinid in my system then is 0.
according to this, the result from
getid(mywavein,ID) is 0

The "mywavein" handle works fine, but trying to close the device via
> waveInClose(@mywavein);

I get the message:
"error 005 the device-access-number you used is invalid"
So did I use the wrong ID to open the device ?
(By the way, the "WAVE_MAPPER"-Constant does not work as an ID, because my compiler tells me that it´s out of range...)
Thanks a lot for your help so far...


0
 
chensuCommented:
The first parameter of waveInOpen is of type LPHWAVEIN while the first parameter of waveInClose is of type HWAVEIN. It looks like from your code that you passed the wrong value. Shouldn't it be

waveInClose(mywavein);

?
0
 
vader1Author Commented:
Thanks for adding your comment !
Actually it didn´t exactly solve my problem, but thanks to you I started thinking about it again. Now I found a way to fix the problem (I think the problem is an error in the mmsystem.hlp´s description of the waveinclose-function, so I might not be the only one to encounter this problem):

var
mywavein:HWaveIn; ** a handle (!!)

function waveInClose(hWaveIn: PHWaveIn (!!??)): Word;
HWAVEIN : hWaveIn (!!??) ** THIS IS A CONTRADICTION, ISN`T IT ??
Specifies a handle (!!??) to the waveform input device.

** actually the function requires a PHWavein , as the function does not accept the actual waveinHANDLE

I tried to do it by:
waveInClose(@mywavein);
which did NOT work,

So i changed it to:
waveInClose(PHWavein(mywavein));
which works fine !

Thanks for helping me !
0
 
chensuCommented:
Apparently, your documentation is wrong.

According to the Microsoft Platform SDK documentation, the function prototype is

MMRESULT waveInClose(HWAVEIN hwi);
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now