EDSDK消息循环在Windows 8.1下不起作用
EDSDK message loop not working under Windows 8.1
我使用的是佳能EDSDK_64 v2.15。我可以在Windows7下使用简单的消息循环接收Canon SDK发送的事件。例如,当我想拍照并等待图像数据时,我使用:
xCanonError = EdsSendCommand(xCanonEOS, kEdsCameraCommand_TakePicture, 0);
if(xCanonError != EDS_ERR_OK)
{
AddLogText(L"sending command TakePicture - error - "+SmartCanon::GetCanonSDKError(xCanonError));
return false;
}
MSG msg;
while(eState == detector_state_busy)
{
if (::GetMessage(&msg, NULL, NULL, NULL) == -1)
{
AddLogText(L" - capture image - waiting for an image - GetMessage() error - " + std::to_wstring(HRESULT_FROM_WIN32(GetLastError())));
break;
}
else
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
Sleep(2);
};
这就是我注册对象处理程序的方式:
xCanonError = EdsSetObjectEventHandler(xCanonEOS, kEdsObjectEvent_All, CSDKHandleObjectEvent, this);
if (xCanonError != EDS_ERR_OK)
{
AddLogText(L"EdsSetObjectEventHandler() - error - "+GetCanonSDKError(xCanonError));
EdsRelease(xCanonEOS);
xCanonEOS = NULL;
EdsTerminateSDK();
return;
}
其中xCanonEOS
为EdsCameraRef
;this
是一个指向类的指针,我用它来完成我的佳能相机的所有工作。这是我的对象事件处理程序函数:
EdsError EDSCALLBACK CSDKHandleObjectEvent(EdsObjectEvent p_sCSDKEvent, EdsBaseRef p_sCSDKObject, EdsVoid* p_pCSDKData)
{
// my class for working with Canon camera
SmartCanon::TDetectorCANON* v_psDetectorCanonEOS = reinterpret_cast<SmartCanon::TDetectorCANON*>(p_pCSDKData);
// a lot of irrelevant code...
v_psDetectorCanonEOS->SetState(detector_state_idle);
return EDS_ERR_OK;
}
我的问题是,同样的代码在Windows8.1下不起作用。程序只进入while
循环,注册的回调函数永远不会被调用
我使用的是VS2013 x64编译器。我的相机是佳能EOS60D。我的应用程序正在使用MFC库。
有人能指出我做错了什么吗?或者提供解决方案来解决这个问题?
我遇到了同样的问题,使用32位版本解决了回调函数。
相关文章:
- 为什么简单的算术减法在"if"条件下不起作用?
- 为什么 ulimit -v 在 Clang 的地址清理器下不起作用?
- G++ C++17 类模板参数推导在非常特殊的情况下不起作用
- EOF有更安全的替代方案吗?它在我的情况下不起作用
- 在函数中声明的 ifStream 对象在发布模式下不起作用
- c++ 选择排序在特定情况下不起作用
- 寻找有关为什么此C++代码在没有引用的情况下不起作用的解释
- Makefile在Linux中工作,但在Windows下不起作用,在子目录中找不到文件
- 句子转换器在存在新行的情况下不起作用
- 为什么 std::void_t 在这种情况下不起作用
- 我的代码在发布模式下不起作用,而在Qt的调试模式下工作
- C++中的dynamic_cast在没有 RTTI 的情况下不起作用;为什么?
- 模板化友元声明在 G++ 5.4.0 下不起作用 - 编译器错误或错误代码
- 为什么SFINAE在这种情况下不起作用?
- POSIX 信号量在高争用/负载下不起作用
- 运算符重载如何工作,为什么在我的情况下不起作用?
- 请帮助我理解为什么SFINAE在这种情况下不起作用
- WinRT 库在发布模式下不起作用
- EDSDK消息循环在Windows 8.1下不起作用
- 为什么#ifndef在这种情况下不起作用