Advertisement
Guest User

Example1

a guest
Aug 8th, 2010
586
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 1.17 KB | None | 0 0
  1. unit Unit33;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  7.   Dialogs, MMDevApi, ActiveX, StdCtrls;
  8.  
  9. type
  10.   TForm33 = class(TForm)
  11.     Button1: TButton;
  12.     procedure FormCreate(Sender: TObject);
  13.     procedure Button1Click(Sender: TObject);
  14.   private
  15.     { Private declarations }
  16.   public
  17.     { Public declarations }
  18.   end;
  19.  
  20. var
  21.   Form33: TForm33;
  22.   endpointVolume: IAudioEndpointVolume = nil;
  23.  
  24. implementation
  25.  
  26. {$R *.dfm}
  27.  
  28.  
  29. procedure TForm33.Button1Click(Sender: TObject);
  30. var
  31.   VolumeLevel: Single;
  32. begin
  33.   if endpointVolume = nil then Exit;
  34.   VolumeLevel := 0.50;
  35.   endpointVolume.SetMasterVolumeLevelScalar(VolumeLevel, nil);
  36.   Caption := Format('%1.8f', [VolumeLevel])
  37. end;
  38.  
  39. procedure TForm33.FormCreate(Sender: TObject);
  40. var
  41.   deviceEnumerator: IMMDeviceEnumerator;
  42.   defaultDevice: IMMDevice;
  43. begin
  44.   CoCreateInstance(CLASS_IMMDeviceEnumerator, nil, CLSCTX_INPROC_SERVER, IID_IMMDeviceEnumerator, deviceEnumerator);
  45.   deviceEnumerator.GetDefaultAudioEndpoint(eRender, eConsole, defaultDevice);
  46.   defaultDevice.Activate(IID_IAudioEndpointVolume, CLSCTX_INPROC_SERVER, nil, endpointVolume);
  47. end;
  48.  
  49. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement