none
CLSID_WICImagingFactory: breaking change since VS11 Beta on Windows 7 RRS feed

  • Question

  • Hi,

    Since the installation of VS11 Beta, the following code is broken on Windows 7:

    #include "stdafx.h"
    
    #include <Windows.h>
    
    #include <wincodec.h>
    #pragma comment(lib, "WindowsCodecs.lib")
    
    int _tmain(int argc, _TCHAR* argv[])
    {
        HRESULT hr = S_OK;
        IWICImagingFactory* pWICFactory = NULL;
    
        hr = ::CoInitialize(NULL);
    
        hr = ::CoCreateInstance(
            CLSID_WICImagingFactory, // Has to be replaced with CLSID_WICImagingFactory1
            NULL,
            CLSCTX_INPROC_SERVER,
            IID_IWICImagingFactory,
            (LPVOID*) (&pWICFactory)
            );
    
        if (SUCCEEDED(hr))
            printf("SUCCEEDED\n");
        else
            printf("FAILED\n");
    
        return 0;
    }
    
    

    On Windows 7, hr is 'REGDB_E_CLASSNOTREG 0x80040154 Class not registered'.

    When creating a project, the latest platform is targetted (Windows 8); in this case, CLSID_WICImagingFactory is defined as CLSID_WICImagingFactory2, which is not registered on Windows 7. The code has to be modified either to use CLSID_WICImagingFactory1 or the project has to be targetted to Windows 7.

    Is this breaking change intended ?

    Sunday, March 4, 2012 3:19 PM

Answers

  • With the Windows 8.0 SDK, you need to build explicitly setting a processor definition of _WIN32_WINNT to 0x0600 for compatibilty with Windows Vista or 0x0601 for compatibily with Windows 7.  Otherwise you will get Windows 8 specific APIs in a number of places.

    See Where is the DirectX SDK? for some notes on using the Windows 8.0 SDK for targeting Windows Vista or Windows 7.

    Friday, July 27, 2012 6:39 PM

All replies

  • Hello,

    Yes, this is an intentional change. Applications which target Windows 8 will get a new version of the WIC imaging factory. If you are running the application on Windows 7 then you must target the Windows 7 platform.

    Simon


    This posting is provided "AS IS" with no warranties, and confers no rights. You assume all risk for your use.
    © Microsoft Corporation. All rights reserved.

    Tuesday, April 24, 2012 9:05 PM
  • With the Windows 8.0 SDK, you need to build explicitly setting a processor definition of _WIN32_WINNT to 0x0600 for compatibilty with Windows Vista or 0x0601 for compatibily with Windows 7.  Otherwise you will get Windows 8 specific APIs in a number of places.

    See Where is the DirectX SDK? for some notes on using the Windows 8.0 SDK for targeting Windows Vista or Windows 7.

    Friday, July 27, 2012 6:39 PM