X64编译成功后waveInOpen崩溃的问题及解决方案

xingyun86 2018-5-8 2272


I've found the problem. It was in our own code

mmRes = waveInOpen(&m_hwi, m_nDeviceID, &wfx, (DWORD)waveInProc, (DWORD)this, 
                                                          CALLBACK_FUNCTION);

Here 4th and 5th parameters were expected as DWORD_PTR but here they were being cast to DWORD. Since sizeof(DWORD) is 4 and sizeof(DWORD_PTR) is 8 on an 64 bit architecture this led to truncation and hence the crash.

So the correct code is:

mmRes = waveInOpen(&m_hwi, m_nDeviceID, &wfx, (DWORD_PTR)waveInProc, (DWORD_PTR)this, 
                                                                  CALLBACK_FUNCTION);


×
打赏作者
最新回复 (0)
查看全部
全部楼主
返回