Solved

delphi: how to get input audio list ?

Posted on 2011-09-05
1
870 Views
Last Modified: 2012-05-12
Hello experts
How can I retrieve the list of installed input devices ? (input = microphone, not audio output)

regards
0
Comment
Question by:yarekGmail
1 Comment
 
LVL 12

Accepted Solution

by:
Hypo earned 500 total points
ID: 36484702
There is a unit called MMSystems that contains most of the functionality you need... if you search through the windows sdk for functions that begin with waveIn, you will find the functions that are used with audio input devices on the system...

see the example below...

/Hypo
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MMSystem, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    ListBox1: TListBox;
    procedure Button1Click(Sender: TObject);
    procedure FormDestroy(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    FWaveInDevices : array of TWaveInCaps;
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure CheckIfError(AResult : MMRESULT);
var aText : String;
    aRes : Cardinal;
begin
  if AResult <> MMSYSERR_NOERROR then begin
    SetLength(aText, 255);
    aRes := waveInGetErrorText(AResult, @aText[1], 255);
    if aRes <> MMSYSERR_NOERROR then
      waveInGetErrorText(aRes, @aText[1], 255);
    aText := PChar(aText);
    raise Exception.Create(aText + ' - Error code: ' + IntToStr(AResult));
  end;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  FWaveInDevices := nil;
end;

procedure TForm1.Button1Click(Sender: TObject);
var i, aCount : integer;
begin
  aCount := waveInGetNumDevs;
  SetLength(FWaveInDevices, aCount);
  for i := 0 to aCount-1 do begin
    CheckIfError(waveInGetDevCaps(i, @FWaveInDevices[i], SizeOf(FWaveInDevices[i])));
    ListBox1.Items.Add(FWaveInDevices[i].szPname);
  end;
end;

end.

Open in new window

0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 89
code issue 8 84
Dev Express grid collapse 2 33
Delphi: Connect to running MS Outlook 4 27
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now