共用方式為


使用 midiOutShortMsg 傳送個別 MIDI 訊息

下列範例會使用 midiOutShortMsg 函 式,將指定的 MIDI 事件傳送至指定的 MIDI 輸出裝置:

UINT sendMIDIEvent(HMIDIOUT hmo, BYTE bStatus, BYTE bData1, 
    BYTE bData2) 
{ 
    union { 
        DWORD dwData; 
        BYTE bData[4]; 
    } u; 
 
    // Construct the MIDI message. 
 
    u.bData[0] = bStatus;  // MIDI status byte 
    u.bData[1] = bData1;   // first MIDI data byte 
    u.bData[2] = bData2;   // second MIDI data byte 
    u.bData[3] = 0; 
 
    // Send the message. 
    return midiOutShortMsg(hmo, u.dwData); 
} 

注意

MIDI 輸出驅動程式不需要先驗證資料,再將資料傳送至輸出埠。 應用程式必須確定只傳送有效的資料。