Board index » delphi » A problem with waveOutOpen (): How to set the callback function ?

A problem with waveOutOpen (): How to set the callback function ?

I can't set the callback function for the waveOutOpen () windows API
call. Here is my callback function:

procedure Callback (hWave: HWAVEOUT; uMsg: UINT; dwInstance:DWORD;
dwParam1:DWORD; dwParam2: DWORD);
begin
if (uMsg = MM_WOM_DONE) then
Application.MessageBox ('done',done',mb_Ok);
end;

and here is my waveOutOpen () system call:

  waveOutOpen (@AHWaveOut,
                 wCount,
                 @AWaveFormatEx,
                 DWORD (@Callback),
                 0,
                 CALLBACK_FUNCTION);

Why doesn't this work ? The system crashes or tells me about an
illegal read...

Help !

 

Re:A problem with waveOutOpen (): How to set the callback function ?


Quote
> procedure Callback (hWave: HWAVEOUT; uMsg: UINT; dwInstance:DWORD;
> dwParam1:DWORD; dwParam2: DWORD);
> begin
> if (uMsg = MM_WOM_DONE) then
> Application.MessageBox ('done',done',mb_Ok);
> end;

All API callbacks use the stdcall calling convention. Try adding stdcall;
at the end of
the function declaration. Also, is the declaration for this function in the
interface of your unit? If not, the DLL can't get to it.

Peter

Other Threads