这个参数是要打开的音频波形输出设备的句柄,也可以是一个设备ID号。 如果使用ID号,可以用0到N-1来标识第1个到第N个设备。 下面是一个MSDN中的例子#include <mmsystem.h> #include <stdlib.h> // the use of waveOutGetVolume() and waveOutSetVolume(). char buffer[40]; char printbuf[80]; UINT uRetVal, uNumDevs; DWORD volume; long lLeftVol, lRightVol; WAVEOUTCAPS waveCaps; // 确保至少有一个音频输出设备 //waveOutGetNumDevs返回设备的数目,0表明目前没有设备,或出现错误 if (uNumDevs = waveOutGetNumDevs()) { itoa((int)uNumDevs, buffer, 10);//转换整形为字符串 wsprintf(printbuf, "Number of devices is %s\n", (LPSTR)buffer); MessageBox(GetFocus(), printbuf, "NumDevs", MB_OK); }// This sample uses a hard-coded 0 as the device ID, but retail // applications should loop on devices 0 through N-1, where N is the // number of devices returned by waveOutGetNumDevs(). //使用waveoutGetDevCaps()函数的情况下,设备参数为ID或HANDLE并不重要 //如果只是播放一个wave文件,这个参数可以设为0. 如果只是播放一个multiple wave 文件, 这个参数可以设为1,代表第2个设备。 if (!waveOutGetDevCaps(0,(LPWAVEOUTCAPS)&waveCaps, sizeof(WAVEOUTCAPS))) { // Verify the device supports volume changes if(waveCaps.dwSupport & WAVECAPS_VOLUME) { // The low word is the left volume, the high word is the right. // Set left channel: 2000h is one-eighth volume (8192 base ten). // Set right channel: 4000h is quarter volume (16384 base ten). uRetVal = waveOutSetVolume(0, (DWORD)0x40002000UL); ...... }
用waveOutOpen函数打开一个回放相应格式的设备 Reverse: Using Low-level Waveform Playback Services http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpreverse.asp这是一个vc的sample
如果使用ID号,可以用0到N-1来标识第1个到第N个设备。
下面是一个MSDN中的例子#include <mmsystem.h>
#include <stdlib.h> // the use of waveOutGetVolume() and waveOutSetVolume().
char buffer[40];
char printbuf[80];
UINT uRetVal, uNumDevs;
DWORD volume;
long lLeftVol, lRightVol; WAVEOUTCAPS waveCaps; // 确保至少有一个音频输出设备
//waveOutGetNumDevs返回设备的数目,0表明目前没有设备,或出现错误
if (uNumDevs = waveOutGetNumDevs())
{
itoa((int)uNumDevs, buffer, 10);//转换整形为字符串
wsprintf(printbuf, "Number of devices is %s\n", (LPSTR)buffer);
MessageBox(GetFocus(), printbuf, "NumDevs", MB_OK);
}// This sample uses a hard-coded 0 as the device ID, but retail
// applications should loop on devices 0 through N-1, where N is the
// number of devices returned by waveOutGetNumDevs().
//使用waveoutGetDevCaps()函数的情况下,设备参数为ID或HANDLE并不重要
//如果只是播放一个wave文件,这个参数可以设为0. 如果只是播放一个multiple wave 文件, 这个参数可以设为1,代表第2个设备。 if (!waveOutGetDevCaps(0,(LPWAVEOUTCAPS)&waveCaps,
sizeof(WAVEOUTCAPS)))
{
// Verify the device supports volume changes
if(waveCaps.dwSupport & WAVECAPS_VOLUME)
{
// The low word is the left volume, the high word is the right.
// Set left channel: 2000h is one-eighth volume (8192 base ten).
// Set right channel: 4000h is quarter volume (16384 base ten).
uRetVal = waveOutSetVolume(0, (DWORD)0x40002000UL);
......
}
Reverse: Using Low-level Waveform Playback Services
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcsample98/html/vcsmpreverse.asp这是一个vc的sample