Homero1225,
Revisa este ejemplo:
Código Delphi
[-]unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, MMSystem;
type
TForm1 = class(TForm)
Edit1: TEdit;
procedure SoundKeyPress(Sender: TObject; var Key: Char);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.SoundKeyPress(Sender: TObject; var Key: Char);
var
SoundKey : string;
i : Integer;
begin
SoundKey := ExtractFilePath(Application.ExeName) + 'Windows Logon Sound.wav';
for i := 1 to 3 do
begin
PlaySound(PAnsiChar(SoundKey), 0, SND_FILENAME or SND_ASYNC);
Sleep(1000);
end;
MessageDlg('Key =' + IntToStr(Ord(Key)) + ' has been pressed', mtInformation, [mbOK], 0);
end;
end.
El Evento OnKeyPress del Control TEdit por medio del procedure TForm1.SoundKeyPress reproducira 3 veces seguidas un archivo .WAV con un intervalo de un segundo entre sonido y mostrara el código ASCII de la tecla presionada.
Espero sea útil
Nelson.