Skip to content

Instantly share code, notes, and snippets.

@xingfuqiu
Created August 15, 2012 02:18
Show Gist options
  • Save xingfuqiu/3354996 to your computer and use it in GitHub Desktop.
Save xingfuqiu/3354996 to your computer and use it in GitHub Desktop.
C++:win7单进程静音h
// VistaVolume.h
#ifndef _VISTAVOLUME_H_
#define _VISTAVOLUME_H_
#include <Windows.h>
#include <Mmdeviceapi.h> // for IMMDeviceEnumerator and IMMDevice
#include <Endpointvolume.h> // for IAudioEndpointVolume, must #define NTDDI_VERSION NTDDI_WINXPSP1 in stdafx.h
#include <Audiopolicy.h>
#include <Audioclient.h>
class CVistaVolume
{
public:
CVistaVolume();
~CVistaVolume();
public:
HRESULT Init();
HRESULT Uninit();
HRESULT SetVolume(float fVolume);
HRESULT GetVolume(float *pfVolume);
HRESULT SetMute(BOOL bMute);
BOOL GetMute();
private:
IMMDeviceEnumerator *m_pEnumerator;
BOOL m_bMute;
};
#endif //_VISTAVOLUME_H_
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment