uses MMSystem
procedure TForm1.btn1Click(Sender: TObject);
var
strPath:string;
mciOpenParms:TMCI_OPEN_PARMS ;
mciPlayParms:TMCI_Play_Parms;
wDeviceID
WORD;
mciCloseParms:TMCI_Generic_Parms;
begin
strPath:=SysUtils.ExtractFilePath(Application.ExeName)+'Test.MID';
showmessage(strpath);
FillChar(mciOpenParms, SizeOf(TMCI_Open_Parms), 0);
mciOpenParms.lpstrDeviceType := 'sequencer';
mciOpenParms.dwCallback:=0;
mciOpenParms.lpstrElementName := PChar(strPath);
mciSendCommand(0,MCI_OPEN,
MCI_OPEN_TYPE or MCI_OPEN_ELEMENT,
DWORD(@mciOpenParms));
wDeviceID:=mciOpenParms.wDeviceID;
mciPlayParms.dwCallback:=Handle;
mciSendCommand(wDeviceID, MCI_PLAY,
MCI_NOTIFY,
DWORD(@mciPlayParms));
end;