Flora Posted October 2, 2014 Share Posted October 2, 2014 I wrote my program using PcommServer based on MFC in Visual Studio 2010. It worked very well until I put the pmacDevice.GetResponseEx into the callback function of timeSetEvent, which is a multi-media timer in winmm.lib. Once it runs to GetResponseEx, exceptions as following will be shown: "First-chance exception at 0x00000000 in ***.exe: 0xC0000005: Access violation reading location 0x00000000." "Unhandled exception at 0x00000000 in ***.exe: 0xC0000005: Access violation reading location 0x00000000." And I add CoInitialize(NULL) in the callback function, it still doesn't work. My question is how to use pmacDevice.GetResponseEx in the timeSetEvent callback function? I attach the code as: timeSetEvent: void CTestDlg::OnBnClickedBtntimer() { TIMECAPS timecaps; UINT wAccuracy_Test,TimerID_Test; if(timeGetDevCaps(&timecaps,sizeof(TIMECAPS))==TIMERR_NOERROR) { wAccuracy_Test= min(max(timecaps.wPeriodMin,1),timecaps.wPeriodMax); timeBeginPeriod(wAccuracy_Test); while (( TimerID_Test = timeSetEvent(1000, wAccuracy_Test,(LPTIMECALLBACK) TestProc, (DWORD)this,TIME_PERIODIC)) == NULL) ;// } } callback function: UINT CTestDlg::TestProc(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2 ) { CoInitializeEx(NULL); char cmdbuf[255]; BSTR retbuf = ::SysAllocString(L""); BOOL pStatus; ((CTestDlg*)theApp.m_pMainWnd)->pmacDevice.GetResponse(0, "I122=3",FALSE, &retbuf,&pStatus); ::SysFreeString(retbuf); CoUninitialize(); return 0; } Open device: void CTestDlg::OnBnClickedBtnopen() { CoInitialize(NULL); testInterface = pmacDevice.CreateDispatch(_T("PcommServer.PmacDevice.1")); if (!testInterface) { AfxMessageBox("Fail to open library!"); return; } BOOL ret; pmacDevice.SelectDevice(NULL,&m_nDevice,&ret); int pbDriverOpen; pmacDevice.Open(m_nDevice, &pbDriverOpen); if(!pbDriverOpen) { AfxMessageBox("Fail to open Device!"); } else { pmacDevice.GetDPRAvailable(m_nDevice); } } Link to comment Share on other sites More sharing options...
steve.milici Posted October 6, 2014 Share Posted October 6, 2014 Please contact our technical support group for help on this issue at: support@deltatau.com. Link to comment Share on other sites More sharing options...
Flora Posted October 8, 2014 Author Share Posted October 8, 2014 Please contact our technical support group for help on this issue at: support@deltatau.com. I did send the email one week ago, but so far there has been no reply from the group. Link to comment Share on other sites More sharing options...
MClement Posted October 10, 2014 Share Posted October 10, 2014 and the response would be good to post here for others to learn from.... Link to comment Share on other sites More sharing options...
Flora Posted October 20, 2014 Author Share Posted October 20, 2014 and the response would be good to post here for others to learn from.... But I have not received any response yet. Link to comment Share on other sites More sharing options...
Flora Posted October 20, 2014 Author Share Posted October 20, 2014 and the response would be good to post here for others to learn from.... But I have not received any response yet. Link to comment Share on other sites More sharing options...
Recommended Posts