cocreateinstance在32bit上崩溃

时间:2015-04-15 15:26:14

标签: c++ com

我正在尝试使用CoCreateInstance()函数实例化WMEncoder,它在64位上工作正常但在32位操作系统版本上崩溃了。

HRESULT hr = E_FAIL;
IWMEncoder2 *g_pEncoder = NULL;

hr = CoInitialize(NULL);
if (FAILED(hr))
    return hr;

hr = CoCreateInstance(CLSID_WMEncoder, NULL, CLSCTX_INPROC_SERVER, IID_IWMEncoder2, (void**)&g_pEncoder);
if (FAILED(hr)) {
    CoUninitialize();
    return hr;
}

即使在64位上,它也会产生访问冲突异常。这是windbg输出:

...
ModLoad: 75580000 761ca000   C:\Windows\syswow64\SHELL32.dll
ModLoad: 6fb40000 6fbc4000   C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.7601.17514_none_ec83dffa859149af\COMCTL32.dll
ModLoad: 74a10000 74a29000   C:\Windows\SysWOW64\OLEPRO32.DLL
ModLoad: 74f70000 74f86000   C:\Windows\SysWOW64\CRYPTSP.dll
ModLoad: 74a50000 74a8b000   C:\Windows\SysWOW64\rsaenh.dll
ModLoad: 73110000 7311e000   C:\Windows\SysWOW64\RpcRtRemote.dll
(1d48.1ea8): Access violation - code c0000005 (first chance)
First chance exceptions are reported before any exception handling.
This exception may be expected and handled.
*** ERROR: Symbol file could not be found.  Defaulted to export symbols for C:\Program Files (x86)\Windows Media Components\Encoder\WMEncEng.dll - 
eax=08b7801f ebx=001807a8 ecx=00000000 edx=00000000 esi=00454c28 edi=00734258
eip=00734258 esp=0280f574 ebp=0280f5bc iopl=0         nv up ei pl nz na po nc
cs=0023  ss=002b  ds=002b  es=002b  fs=0053  gs=002b             efl=00010202
00734258 c7442404284c4500 mov     dword ptr [esp+4],454C28h ss:002b:0280f578=001807a8

1 个答案:

答案 0 :(得分:0)

如果您只安装了64位版本,则无法以32位代码实例化它。