Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

delphi: how to get input audio list ?

Posted on 2011-09-05
1
Medium Priority
?
1,067 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 2000 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
Integration Management Part 2
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses

877 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