-
大小: 7KB文件類型: .rar金幣: 2下載: 0 次發(fā)布日期: 2021-06-13
- 語(yǔ)言: C/C++
- 標(biāo)簽: qt??c++??系統(tǒng)音量??
資源簡(jiǎn)介
qt, c++調(diào)用系統(tǒng) windows api 調(diào)節(jié)系統(tǒng)音量,調(diào)節(jié)麥克風(fēng)音量

代碼片段和文件信息
#include?“StdAfx.h“
#include?“MixerWrap.h“
#include?
#include?
#include?
#include?
#include?
using?namespace?std;
#include?
#include?
#include?
#include?
#define?TOWCHAT(x)?QStringLiteral(x).toStdWString().data()
#define?SAFE_RELEASE(punk)??\
if?((punk)?!=?NULL)??\
#define?EXIT_ON_ERROR(hres)?? if?(FAILED(hres))?{?goto?Exit;?}
#define?SAFE_RELEASE(punk)?? if?((punk)?!=?NULL)??{?(punk)->Release();?(punk)?=?NULL;?}
HRESULT?getMicrophoneBoostVolumeLevel(IMMDevice?*pEndptDev?IAudioVolumeLevel**?ppVolumeLevel)
{
HRESULT?hr?=?S_OK;
DataFlow?flow;
IDeviceTopology?*pDeviceTopology?=?NULL;
IConnector?*pConnFrom?=?NULL;
IConnector?*pConnTo?=?NULL;
IPart?*pPartPrev?=?NULL;
IPart?*pPartNext?=?NULL;
*ppVolumeLevel?=?NULL;
wchar_t?microphoneBoostName[]?=?L“麥克風(fēng)加強(qiáng)“;//if?your?system?language?is?Englishthe?name?is?“microphone?boost“
if?(pEndptDev?==?NULL)
{
EXIT_ON_ERROR(hr?=?E_POINTER)
}
//?Get?the?endpoint?device‘s?IDeviceTopology?interface.
hr?=?pEndptDev->Activate(
__uuidof(IDeviceTopology)?CLSCTX_ALL?NULL
(void**)&pDeviceTopology);
EXIT_ON_ERROR(hr)
//?The?device?topology?for?an?endpoint?device?always
//?contains?just?one?connector?(connector?number?0).
hr?=?pDeviceTopology->GetConnector(0?&pConnFrom);
SAFE_RELEASE(pDeviceTopology)
EXIT_ON_ERROR(hr)
//?Make?sure?that?this?is?a?capture?device.
hr?=?pConnFrom->GetDataFlow(&flow);
EXIT_ON_ERROR(hr)
if?(flow?!=?Out)
{
//?Error?--?this?is?a?rendering?device.
//EXIT_ON_ERROR(hr?=?AUDCLNT_E_WRONG_ENDPOINT_TYPE)
}
//?Outer?loop:?Each?iteration?traverses?the?data?path
//?through?a?device?topology?starting?at?the?input
//?connector?and?ending?at?the?output?connector.
while?(TRUE)
{
BOOL?bConnected;
hr?=?pConnFrom->IsConnected(&bConnected);
EXIT_ON_ERROR(hr)
//?Does?this?connector?connect?to?another?device?
if?(bConnected?==?FALSE)
{
//?This?is?the?end?of?the?data?path?that
//?stretches?from?the?endpoint?device?to?the
//?system?bus?or?external?bus.?Verify?that
//?the?connection?type?is?Software_IO.
ConnectorType??connType;
hr?=?pConnFrom->GetType(&connType);
EXIT_ON_ERROR(hr)
if?(connType?==?Software_IO)
{
break;??//?finished
}
EXIT_ON_ERROR(hr?=?E_FAIL)
}
//?Get?the?connector?in?the?next?device?topology
//?which?lies?on?the?other?side?of?the?connection.
hr?=?pConnFrom->GetConnectedTo(&pConnTo);
EXIT_ON_ERROR(hr)
SAFE_RELEASE(pConnFrom)
//?Get?the?connector‘s?IPart?interface.
hr?=?pConnTo->QueryInterface(
__uuidof(IPart)?(void**)&pPartPrev);
EXIT_ON_ERROR(hr)
SAFE_RELEASE(pConnTo)
//?Inner?loop:?Each?iteration?traverses?one?link?in?a
//?device?topology?and?looks?for?input?multiplexers.
whil
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件??????56604??2017-10-30?11:22??MixerWrap.cpp
?????文件???????1106??2014-01-09?15:15??MixerWrap.h
-----------?---------??----------?-----??----
????????????????57710????????????????????2
評(píng)論
共有 條評(píng)論