문제

I have Win32 C++ sample application that uses Windows Image Component in Visual Studio Pro 2012 Update 2. I built this app for X86 and tested in Windows 7 X64 SP1 and Windows 7 X86 SP1. It works fine with the first one and it fails on the later with "class not registered".

If I build the same code with VS2008 it works fine.

The WIC instance is created in the sample app as follows:

#include "wincodec.h"
...
case WM_CREATE:
{
IWICImagingFactory *m_pIWICFactory;  
HRESULT hr = S_OK;

CoInitialize(NULL);
// create WIC factory (m_pIWICFactory)
hr = CoCreateInstance(
    &CLSID_WICImagingFactory,
    NULL,
    CLSCTX_INPROC_SERVER,
    &IID_IWICImagingFactory, 
    &m_pIWICFactory);
if (!SUCCEEDED(hr))
    MessageBox(NULL, 
        L"CoCreateInstance(..IID_IWICImagingFactory..) failed!", 
        L"", MB_OK);
else
    MessageBox(NULL, 
        L"CoCreateInstance(..IID_IWICImagingFactory..) succeeded!", 
        L"", MB_OK);

CoUninitialize();
}
break;
...

What could I be doing wrong?

도움이 되었습니까?

해결책

There is a breaking change in VS2012 because it targets Windows 8 by default.

The solution is to specify CLSID_WICImagingFactory1 instaed of CLSID_WICImagingFactory because the latter resolves to CLSID_WICImagingFactory2, which does not exist in Windows 7.

So try this

hr = CoCreateInstance(&CLSID_WICImagingFactory1, NULL, CLSCTX_INPROC_SERVER,
         &IID_IWICImagingFactory, &m_pIWICFactory);
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top