各位高手,要设置系统音量该用哪个API呢?具体如何实现?

ender 2000-12-20 05:25:00
我只找到一个API是设置WAV设备的音量的,而且也用不好,能不能直接改变系统的音量呢(就是WINDOWS右下方的哪个小喇叭实现的工作)?

谢谢大家!
...全文
795 25 打赏 收藏 转发到动态 举报
写回复
用AI写文章
25 条回复
切换为时间正序
请发表友善的回复…
发表回复
softwarewj 2001-01-17
  • 打赏
  • 举报
回复
录音问题,搞定了。
softwarewj 2001-01-16
  • 打赏
  • 举报
回复
以上是参考我的源程序给出的调节主音量的代码。

不过我现在在录音时调节MIC音量大小方面遇到点小障碍。本该是录音时调节,却搞成回放时调节。正在解决中……,也希望有实之士给出参考意见。
softwarewj 2001-01-16
  • 打赏
  • 举报
回复
HMIXER hMixer;
MMRESULT mmr;
MIXERCONTROL mix
MIXERLINECONTROLS mixlc;
MIXERLINE mxl;
MIXERCONTROLDETAILS mxcd;
MIXERCONTROLDETAILS_UNSIGNED vol;

DWORD dwVolume=5000;

mmr=mixerOpen(&hMixer,0,0,0);
if(mmr==MMSYSERR_NOERROR)
{
ZeroMemory(&mxl,sizeof(mxl));
mxl.cbStruct=sizeof(mxl);
mxl.dwComponentType=MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
res=mixerGetLineinfo((HMIXEROBJ)hmix,&mxl,MIXER_GETLINEINFOF_COMPONENTTYPE);
if(res!=MMSYSERR_NOERROR)
return FALSE;

ZeroMemory(&mix,sizeof(MIXERCONTROL));
mix.cbStruct=sizeof(MIXERCONTROL);

ZeroMemory(&mixlc,sizeof(mixlc));
mixlc.cbStruct=sizeof(mixlc);
mixlc.dwLineID=mxl.dwLineID;
mixlc.dwControl=MIXERCONTROL_CONTROLTYPE_VOLUME;
mixlc.cControls=1;
mixlc.cbmxctrl=sizeof(MIXERCONTROL);
mix1c.pamxctrl=&mix;

res=mixerGetLineControls((HMIXEROBJ)hmix,mixlc,MIXER_GETLINECONTROLSF_ONEBYTYPE);
if(res ==MMSYSERR_NOERROR)
{
vol.dwValue=dwVolume;


ZeroMemory(&mxcd,sizeof(mxcd));
mxcd.cbStruct=sizeof(mxcd);
mxcd.cMultipleItems=0;
mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED/*vol*/);
mxcd.paDetails = &vol;
mxcd.dwControlID = mix.dwControlID;
mxcd.cChannels = 1;
mixerSetControlDetails((HMIXEROBJ)hmix,&mxcd,MIXER_SETCONTROLDETAILSF_VALUE);

}
}

try.......
ender 2001-01-11
  • 打赏
  • 举报
回复
555,你说清楚点好不好啊?
softwarewj 2001-01-10
  • 打赏
  • 举报
回复
主音量compnentType是speaker不是wave.
请参考mixer相关资料
softwarewj 2001-01-07
  • 打赏
  • 举报
回复
这个事情我正在做。
老板叫我明天搞掂。
等我试过成功了,就告诉你。
wxz 2000-12-25
  • 打赏
  • 举报
回复
右下角的哪个小喇叭?你监控一下注册表吧,就知道有多么麻烦。不过,现成的函数可能没有。
ender 2000-12-25
  • 打赏
  • 举报
回复
诶,各位老大,请看仔细我的问题!!!
用waveOutSetVolume函数的方法我早就会了,但这个是控制WAVE设备的音量的!
我想知道的是控制系统的音量,就是你右下角的哪个小喇叭干的事!
有人知道没?
wxz 2000-12-24
  • 打赏
  • 举报
回复
yjz回复于2000-12-21 15:50:00
WORD right, left;
DWORD vol;
right=1000;
left=2000;
vol=( (right<<16) ^ left );
MMRESULT waveOutSetVolume(
HWAVEOUT hwo,
DWORD dwVolume
);
kwhei回复于2000-12-22 1:16:00
WAVE设备的HANDLE可以直接设置为0,会以默认值进行
-----------------------
老兄,你应该给分了
哎,给你发了一个vcl,也不知你会不会用
sundayboys 2000-12-24
  • 打赏
  • 举报
回复
去下面网址看看:
http://www.cpcw.com/2000/48/00481801.htm
monkey79 2000-12-23
  • 打赏
  • 举报
回复
关注(E-mail to me )
monkey5258@china.com
OICQ:2385624
ender 2000-12-22
  • 打赏
  • 举报
回复
555
我就是把HANDLE直接设置为0的,结果WAVEOUT的音量倒是能改变,不过左右均衡也被改变了,只有左边的喇叭能发声了!
所以我估计不对!
另外我还想知道怎么才能设置系统的音量!
谢谢!
kwhei 2000-12-22
  • 打赏
  • 举报
回复
WAVE设备的HANDLE可以直接设置为0,会以默认值进行
yjz 2000-12-21
  • 打赏
  • 举报
回复
The waveOutSetVolume function sets the volume level of the specified waveform-audio output device.

MMRESULT waveOutSetVolume(

HWAVEOUT hwo,
DWORD dwVolume
);


Parameters

hwo

Handle of an open waveform-audio output device. This parameter can also be a device identifier.

dwVolume

New volume setting. The low-order word contains the left-channel volume setting, and the high-order word contains the right-channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of dwVolume specifies the volume level, and the high-order word is ignored.

http://xayyy.go.163.com
yjz 2000-12-21
  • 打赏
  • 举报
回复
The auxGetVolume function retrieves the current volume setting of the specified auxiliary output device.

MMRESULT auxGetVolume(
UINT uDeviceID,
LPDWORD lpdwVolume
);


Parameters

uDeviceID

Identifier of the auxiliary output device to be queried.

lpdwVolume

Address of a variable to be filled with the current volume setting. The low-order word of this location contains the left channel volume setting, and the high-order word contains the right channel setting. A value of 0xFFFF represents full volume, and a value of 0x0000 is silence.
If a device does not support both left and right volume control, the low-order word of the specified location contains the volume level.
The full 16-bit setting(s) set with the auxSetVolume function are returned, regardless of whether the device supports the full 16 bits of volume-level control.


http://xayyy.go.163.com
ender 2000-12-21
  • 打赏
  • 举报
回复
啊!
难道竟然没人知道吗?
是不是我给我分太少了?
不过我的新来的,分不多啊!
ender 2000-12-21
  • 打赏
  • 举报
回复
谢谢!
yjz 2000-12-21
  • 打赏
  • 举报
回复
明天回答你。
ender 2000-12-21
  • 打赏
  • 举报
回复
关键是我不知道怎么取得WAVE设备的HANDLE
yjz 2000-12-21
  • 打赏
  • 举报
回复
WORD right, left;
DWORD vol;
right=1000;
left=2000;
vol=( (right<<16) ^ left );
加载更多回复(5)

1,222

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧