procedure OpenFile(
Handle: hWnd);
var
Buf: array[0..MAX_PATH] of Char;
ofn: TOpenFileName;
begin
ZeroMemory(@Buf, SizeOf(Buf));
ofn.lStructSize := SizeOf(TOpenFileName);
ofn.hWndOwner :=
Handle;
ofn.hInstance := hInstance;
ofn.lpstrFilter := 'All playable files (*.wav, *.mid[i], *.rmi, *.mid)|' +
'*.wav; *.mid; *.midi; *.rmi; *.mid|' +
'Wave files (*.wav)|*.wav' +
'Sequencer files (*.mid[i], *.rmi)|*.mid; *.midi; *.rmi' +
'Audio CD tracks (*.cda)|*.cda';
ofn.nFilterIndex := 0;
ofn.lpstrFile := Buf;
ofn.nMaxFile := SizeOf(Buf);
ofn.Flags := OFN_FILEMUSTEXIST or OFN_PATHMUSTEXIST or OFN_LONGNAMES;
ofn.pvReserved := nil;
ofn.dwReserved := 0;
if GetOpenFileName(ofn) then begin
mciSendString('close sound', nil, 0, 0);
FileName := Buf;
mciSendString(PChar('open "' + FileName + '" alias sound'), nil, 0, 0);
end;
end;