procedure TForm1.Button1Click(Sender: TObject);
var
handle: HMIDIOUT;
begin
// Open default MIDI Out device */
if midiOutOpen(@handle, Cardinal(-1), 0, 0, CALLBACK_NULL) =0 then
begin
// Output the C note (ie, sound the note) */
midiOutShortMsg(handle , $00403C90);
// Output the E note */
midiOutShortMsg(handle, $00404090);
// Output the G note */
midiOutShortMsg(handle, $00404390);
// Here you should insert a delay so that you can hear the notes sounding */
Sleep(1000);
// Now let's turn off those 3 notes */
midiOutShortMsg(handle, $00003C90);
midiOutShortMsg(handle, $00004090);
midiOutShortMsg(handle, $00004390);
// Close the MIDI device */
midiOutClose(handle);
end;