WaveInProc, WaveOutProc and Wave Functions

I have written a dll for playing and recording files. Because it has no window handle, I use CALLBACK_FUNCTION in the WaveOutOpen and WaveInOpen and declare the callback function WaveOutProc and WaveInProc. When getting WM_DONE or WIM_DATA, I will
add next buffer and call WaveOutWrite in playging or calling
waveinaddbuffer in recording. However, the functions are
hanged in NT SP5 if I call those wave functions inside the waveInProc or waveOutProc. I see the help saying that only some system function can be called inside the function. But I get worked
in win95.

My question is how to get around this problem in NT SP5?
Can I get any window handle and have a standard
WNDPROC callback to get window message inside the DLL?
if so, how can I do that?


Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You have not to add buffers inside callback proc even under Win95.

Create the hidden window inside the DLL initialization proc and use this window as callback.

You can also create thread, and post message to that thread from the callback function.


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
TorusAuthor Commented:
Can you give me a example?
What kind of example? How to create a window? It is simple enough.

Well, something like this:

#define WMDONE WM_USER+1

HWND hWin;
BOOL DllMain(hInstance...fdwReason...)
  if(fdwReason==DLL_PROCESS_ATTACH) {
  return TRUE;

LRESULT YourWindowProc(HWND w,UINT uMsg,...)
   switch(uMsg) {
   case WMDONE:
       // Free old buffer here    
       // Add new buffer here.
      return DefWindowProc(...)
   return 0;

void CALLBACK waveOutProc(
  HWAVEOUT hwo,      
  UINT uMsg,        
  DWORD dwInstance,  
  DWORD dwParam1,    
  DWORD dwParam2    
  if(uMsg==WOM_DONE) {
Or specify hWin handle in the waveOutOpen (waveInOpen) call, so there will no need in waveOutProc.

The better way is to take any appropiate sample from the SDK.
TorusAuthor Commented:
Yup, I want to use the CALLBACK_WINDOW and get rid of the waveInProc. If so, why can I set up the "YourWindowProc" as a default
message handler? it is necessary to use registerClassEx to do that?

TorusAuthor Commented:
OK, I got it with using RegisterClass.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.