IWMPCore析构函数崩溃

时间:2015-10-10 23:40:10

标签: c++ com wmp

我正在尝试开发一个c ++程序来操作WMP库。尽管是WMP的新手(也是COM的新手),但我还是做得很好。但无论我成功做什么,我的程序总是在主要结束时崩溃。这是最小的例子:

#include "wmp.h"
#include "atlcomcli.h"
int main()
{
    CoInitialize(NULL);
    CComPtr<IWMPCore> spCore;
    HRESULT hr = ::CoCreateInstance(__uuidof(WindowsMediaPlayer),
                                    NULL,
                                    CLSCTX_INPROC_SERVER,
                                    __uuidof(spCore),
                                    (void **) &spCore);
    spCore->close();      // Removing this doesn't help
    // spCore->Release(); // Doesn't compile: can't access private member
    CoUninitialize();
    return 0;
}

崩溃发生在atlcomcli.h:

~CComPtrBase() throw()
{
    if (p)
    p->Release(); // p has the value that was assigned to spCore
                  // read access fail flagged here
}

拜托,谁能告诉我如何处理IWMPCore界面? (我在Vista上使用Visual Studio 2005)

0 个答案:

没有答案