PeekMessage C ++ 64位

时间:2012-02-13 18:42:29

标签: c++ 64-bit peekmessage

我在WinMain函数中使用以下代码:

// Main message loop:
bool noQuit = true;
while (noQuit)
{
    if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
    {
        TranslateMessage(&msg);
        DispatchMessage(&msg);

        if (msg.message == WM_QUIT)
            noQuit = false;
    }
    else
    {
        DrawFrame();
    }
}

当我使用32位(Win32)平台编译时,这很好用。在64位(x64)平台下,代码编译得很好,但是当我运行它时会崩溃。使用调试器,我发现它在PeekMessage行上出现访问冲突时出错。这只发生在64位,但我想知道为什么会这样?有什么我做错了或者我应该知道64位我做错了吗?

我发现它真的很奇怪,因为它并不总是在循环的第一步出错,有时它是第二次甚至第三次,但它总是在具有相同访问冲突的PeekMessage行上停止。

请评论是否有助于我发布更多代码而不仅仅是这部分(我99%确定这是发生错误的地方)。

谢谢!

修改 的 这是访问flash ocx的类的构造函数....

CFlashDXPlayer::CFlashDXPlayer(HMODULE flashDLL, unsigned int width, unsigned int height)
{
m_userData = NULL;
m_flashInterface = NULL;
m_oleObject = NULL;
m_windowlessObject = NULL;
m_lastMouseX = 0;
m_lastMouseY = 0;
m_lastMouseButtons = 0;

m_dirtyFlag = false;

m_width = width;
m_height = height;

m_controlSite.Init(this);
m_controlSite.AddRef();

m_alphaBlackDC = NULL;
m_alphaBlackBitmap = NULL;
m_alphaBlackBuffer = NULL;
m_alphaWhiteDC = NULL;
m_alphaWhiteBitmap = NULL;
m_alphaWhiteBuffer = NULL;

HRESULT hr;

typedef HRESULT (__stdcall *DllGetClassObjectFunc)(REFCLSID rclsid, REFIID riid, LPVOID * ppv);

if (flashDLL != NULL)
{
    IClassFactory* aClassFactory = NULL;
    DllGetClassObjectFunc aDllGetClassObjectFunc = (DllGetClassObjectFunc) GetProcAddress(flashDLL, "DllGetClassObject");
    hr = aDllGetClassObjectFunc(CLSID_ShockwaveFlash, IID_IClassFactory, (void**)&aClassFactory);

    if (FAILED(hr))
        return;

    aClassFactory->CreateInstance(NULL, IID_IOleObject, (void**)&m_oleObject);
    aClassFactory->Release();   
}
else
{
    hr = CoCreateInstance(CLSID_ShockwaveFlash, NULL, CLSCTX_INPROC_SERVER, IID_IOleObject, (void**)&m_oleObject);

    if (FAILED(hr))
        return;
}

IOleClientSite* pClientSite = NULL;
hr = m_controlSite.QueryInterface(__uuidof(IOleClientSite), (void**)&pClientSite);
if (FAILED(hr))
    return;

hr = m_oleObject->SetClientSite(pClientSite);
if (FAILED(hr))
    return;

hr = m_oleObject->QueryInterface(__uuidof(IShockwaveFlash), (void**)&m_flashInterface);
if (FAILED(hr))
    return;

m_flashInterface->DisableLocalSecurity();
m_flashInterface->PutEmbedMovie(FALSE);
m_flashInterface->PutAllowScriptAccess(L"always");
SetTransparencyMode(IFlashDXPlayer::TMODE_OPAQUE);
SetQuality(IFlashDXPlayer::QUALITY_HIGH);

hr = m_oleObject->DoVerb(OLEIVERB_INPLACEACTIVATE, NULL, pClientSite, 0, NULL, NULL);
assert(SUCCEEDED(hr));

pClientSite->Release();

hr = m_oleObject->QueryInterface(__uuidof(IOleInPlaceObjectWindowless), (void**)&m_windowlessObject);
assert(SUCCEEDED(hr));

m_flashSink.Init(this);
m_flashSink.AddRef();

// Resize player
ResizePlayer(width, height);
}

并且为flashDLL传递的内容是m_FlashLibHandle,其中

m_flashLibHandle = LoadLibrary(L"Flash11e.ocx");

0 个答案:

没有答案