資源簡介
qt, c++調用系統 windows api 調節系統音量,調節麥克風音量

代碼片段和文件信息
#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“麥克風加強“;//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
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件??????56604??2017-10-30?11:22??MixerWrap.cpp
?????文件???????1106??2014-01-09?15:15??MixerWrap.h
-----------?---------??----------?-----??----
????????????????57710????????????????????2
評論
共有 條評論