Click here to Skip to main content
15,892,537 members
Articles / Programming Languages / C++

Set Audio Endpoints System Wide in Vista/Windows 7

Rate me:
Please Sign up or sign in to vote.
4.43/5 (4 votes)
7 Jan 2011CPOL3 min read 81.1K   2.7K   10  
An article on how to set system wide audio endpoints programmatically.
//---------------------------------------------------------------------------

#ifndef AudioMainH
#define AudioMainH
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
#include "LMDButton.hpp"
#include "LMDCustomButton.hpp"
#include "LMDCustomScrollBox.hpp"
#include "LMDListBox.hpp"
#include "LMDCustomComponent.hpp"
#include "LMDStarter.hpp"
#include "LMDStorBase.hpp"
#include "LMDStorFormHook.hpp"
#include "LMDStorPropertiesStorage.hpp"
#include <ComCtrls.hpp>
#include <Menus.hpp>
#include <ExtCtrls.hpp>
#include <Graphics.hpp>
#define TRAY_NOTIFYICON (WM_APP+100)
typedef BOOL WINAPI EnumProc(__in_opt HWND hWndParent,__in WNDENUMPROC lpEnumFunc,
										__in LPARAM lParam);



//---------------------------------------------------------------------------
class TAudio : public TForm
{
__published:	// IDE-managed Components
	TListView *lvEndpoint;
	TButton *cbClose;
	TPopupMenu *PopUpMenu;
	TMenuItem *Quit1;
	TMenuItem *Show1;
	TImage *Image1;
	TTimer *Timer1;
	TButton *Button1;
	TButton *Button2;
	TButton *Button3;
	void __fastcall cbCloseClick(TObject *Sender);
	void __fastcall FormShow(TObject *Sender);
	void __fastcall FormCreate(TObject *Sender);
	void __fastcall FormClose(TObject *Sender, TCloseAction &Action);
	void __fastcall PopUpMenuItemsClick(TObject *Sender);
	void __fastcall lvEndpointClick(TObject *Sender);
	int __fastcall IconHandler(tagMSG &Msg);
	void __fastcall SetTrayIcon(HICON welke,bool Update);
	void __fastcall Quit1Click(TObject *Sender);
	void __fastcall Show1Click(TObject *Sender);
	void __fastcall Timer1Timer(TObject *Sender);
	void __fastcall Button1Click(TObject *Sender);
	void __fastcall Button2Click(TObject *Sender);
	void __fastcall Button3Click(TObject *Sender);

protected:
BEGIN_MESSAGE_MAP
MESSAGE_HANDLER(TRAY_NOTIFYICON, tagMSG, IconHandler)
END_MESSAGE_MAP(TForm)
private:	// User declarations
public:		// User declarations
	 int MaxItemCount;
	 bool CanClose;
	 bool SureClose;
	 bool NotDone;
	 POINT popup;
	 HICON anIcon;
	 ITaskbarList *ShellTaskBar;
	 TStringList *Switches;
	__fastcall TAudio(TComponent* Owner);
};
//---------------------------------------------------------------------------
extern PACKAGE TAudio *Audio;

//---------------------------------------------------------------------------
#endif

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Retired
France France
Used to own a software development enterprise from the late 70's to the mid 90's, worked as systems analyst/programmer in that enterprise

Comments and Discussions