All pastes #767549 Raw Edit

Someone

public text v1 · immutable
·published 2007-11-09 20:59 UTC
rendered paste body
#ifndef _INC_MMSYSTEM
#include "mmsystem.h"
#endif

BOOL wrapper(int handle, int welchefunktion, char sysEx) 
{
/* neu start */
MIDIHDR midiHdr;
HANDLE hbuffer
UINT err;

hBuffer = GlobalAlloc(GHND, sizeof(sysEx));
if(hbuffer)
{
 midiHdr.lpData = (LPBYTE)GlobalLock(hBuffer);
 midiHdr.dwBufferLength = sizeof(sysEx);
 midiHdr.dwFlags = 0;

/* neu pause */
BOOL result=false;
HMODULE hWinMM=LoadLibrary("winmm.dll");
if (hWinMM) 
{
	typedef MMRESULT (WINAPI*midiOutPrepareHeader_Type)(HMIDIOUT hmo,LPMIDIHDR lpMidiOutHdr,UINT cbMidiOutHdr);
	typedef MMRESULT (WINAPI*midiOutLongMsg_Type)(HMIDIOUT hmo,LPMIDIHDR lpMidiOutHdr,UINT cbMidiOutHdr);
	typedef MMRESULT (WINAPI*midiOutUnprepareHeader_Type)(HMIDIOUT hmo,LPMIDIHDR lpMidiOutHdr,UINT cbMidiOutHdr);
	
	midiOutPrepareHeader_Type pmidiOutPrepareHeader=(midiOutPrepareHeader_Type)GetProcAddress(hWinMM,"midiOutPrepareHeader");
	midiOutLongMsg_Type pmidiOutLongMsg=(midiOutLongMsg_Type)GetProcAddress(hWinMM,"midiOutLongMsg");
	midiOutUnprepareHeader_Type pmidiOutUnprepareHeader=(midiOutUnprepareHeader_Type)GetProcAddress(hWinMM,"midiOutUnprepareHeader");
	
	if (pmidiOutPrepareHeader && pmidiOutLongMsg && pmidiOutUnprepareHeader )
	{
		//we now have all 3 function pointers and can call those functions...
		case(welchefunktion==0)
                {
                 MMRESULT ret=pmidiOutPrepareHeader(handle,&midiHdr,sizeof(MIDIHDR)); 
                }
		case(welchefunktion==1)
                {
                 MMRESULT ret=pmidiOutLongMsg(handle,&midiHdr,sizeof(MIDIHDR)); 
                }
		case(welchefunktion==2)
                {
                 MMRESULT ret=pmidiOutUnprepareHeader(handle,&midiHdr,sizeof(MIDIHDR)); 
                }
                else {ret==1231}
		result=(ret==0);
	}
	
	FreeLibrary(hWinMM);
}

return result;
}