EDSDK消息循环在Windows 8.1下不起作用

EDSDK message loop not working under Windows 8.1

本文关键字:1下 不起作用 Windows 消息 循环 EDSDK      更新时间:2023-10-16

我使用的是佳能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;
    }

其中xCanonEOSEdsCameraRefthis是一个指向类的指针,我用它来完成我的佳能相机的所有工作。这是我的对象事件处理程序函数:

    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位版本解决了回调函数。