mcisendstring播放音乐时怎么调整音量?

RT
2024-12-26 22:57:33
推荐回答(1个)
回答1:

TCHAR cmd[256];
wsprintf(cmd,"status %s volume",shortPath);
TCHAR volume[256];//用cmd命令获取当前音量,是字符串类型的,存放在volume中
mciSendString(cmd,volume, sizeof(volume), 0 );
int v0=atoi(volume);//把字符串类型转为Internet型,要include
wsprintf(cmd,"setaudio %s volume to %i",shortPath,v0+200);//修改音量
mciSendString(cmd,"",0,NULL);
//上面是增加音量的,减小音量只需修改v0+200,为v0-200,这个步长得选好,我折腾了好几次,否则不明显