不用MediaPlayer播放Midi
点击次数:70 次 发布日期:2008-11-09 08:40:59 作者:源代码网
|
源代码网推荐 uses 源代码网推荐 Windows, Classes, Forms, MMSystem, WinProcs; 源代码网推荐 源代码网推荐 var 源代码网推荐 wDeviceID: Word; 源代码网推荐 PlayWindow: HWnd; 源代码网推荐 源代码网推荐 procedure OpenMCI(PWindow: HWnd; FileName, DeviceType: PChar); 源代码网推荐 var 源代码网推荐 OpenParms: Tmci_Open_Parms; 源代码网推荐 Style: LongInt; 源代码网推荐 begin 源代码网推荐 PlayWindow := PWindow; 源代码网推荐 OpenParms.lpstrDeviceType := DeviceType; 源代码网推荐 OpenParms.lpstrElementName := FileName; 源代码网推荐 Style := Mci_Open_Type or Mci_Open_Element; 源代码网推荐 mciSendCommand(0, MCI_OPEN, Style, LongInt(@OpenParms)); 源代码网推荐 wDeviceID := OpenParms.wDeviceID; 源代码网推荐 end; 源代码网推荐 源代码网推荐 procedure PlayMCI; 源代码网推荐 var 源代码网推荐 Info: TMci_Play_Parms; 源代码网推荐 begin 源代码网推荐 Info.dwCallback := PlayWindow; 源代码网推荐 mciSendCommand(wDeviceID, MCI_PLAY, Mci_Notify, LongInt(@Info)); 源代码网推荐 end; 源代码网推荐 源代码网推荐 procedure MidiPlay(MidiName: PChar); 源代码网推荐 const 源代码网推荐 DevType: PChar="Sequencer"; 源代码网推荐 begin 源代码网推荐 if MidiName = "StopMidi" then 源代码网推荐 CloseMCI 源代码网推荐 else 源代码网推荐 begin 软件开发网 www.mscto.com 源代码网推荐 OpenMci(Application.Handle, MidiName, DevType); 源代码网推荐 PlayMci; 源代码网推荐 end; 源代码网推荐 end; 源代码网推荐 源代码网推荐 procedure CloseMCI; 源代码网推荐 begin 源代码网推荐 mciSendCommand(wDeviceID, MCI_CLOSE, 0, 0); 源代码网推荐 wDeviceID := 0; 源代码网推荐 end; 源代码网推荐 源代码网推荐 end. 源代码网推荐 源代码网推荐 使用方法: 源代码网推荐 MidiPlay("Feeling.mid")); // 注意,这里必须是 PChar 或 char* 源代码网推荐 MidiPlay("StopMidi"); 源代码网推荐 源代码网供稿. |
