Wednesday, January 5, 2011

Check To See If Sound Card Is Present

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

function isSoundCard : longint; stdcall;
         external 'winmm.dll' name 'waveOutGetNumDevs';

procedure TForm1.Button1Click(Sender: TObject);
begin
  if isSoundCard > 0 then Showmessage('There IS a sound card.')
  else ShowMessage('There is NO sound card.');
end;

end.

The easiest way to find out if a sound card is present on a system is to go ask the winmm.dll about it, as with the isSoundCard function in the example above.  If the value returned is greater than zero, then a sound card is on the system.
Though we show it here with just a button-click test and ShowMessage, a more typical use for this would be in applications that use sound for accents like button clicks or splash screen openers. The isSoundCard function would then be used to check to see if a sound card was available, prior to making a sound call.

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum