Using Color Management Modules (CMM)

Color Management Modules (CMMs) are modules of WCS code that use the information in device profiles to perform color conversion and color mapping. Application developers should not have to implement CMMs. Microsoft provides the default CMM. However, if you do write software that requires the use of specialized color conversion and color mapping algorithms, you may create one.

Note   CMM entry points are not API functions and should not be called by applications.

When CMMs are installed, the installation program registers them in the Windows registry. Applications can enumerate the registered CMMs and select one using the SelectCMM function. The following sample application demonstrates how to enumerate all registered CMMs.

#include <stdio.h>
#include <stdlib.h>
#include <stddef.h>
#include <string.h>
#include <mbstring.h>
#include <windows.h>
#include <icm.h>

#ifdef WINDOWS_98
TCHAR  gszICMatcher[] = __TEXT(
TCHAR  gszICMatcher[] = __TEXT(
  "SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\ICM\\ICMatchers");

_CRTAPI1 main (int argc, char *argv[])
    DWORD dwNumCMM = 0;

    DWORD dwErr = RegCreateKey(HKEY_LOCAL_MACHINE,
                 gszICMatcher, &hkCMM);
    DWORD dwMaxName, dwMaxValue;
    DWORD dwInfoErr = RegQueryInfoKey(&hkCMM, NULL, NULL,
                                NULL, NULL, NULL, NULL, NULL,
                                &dwMaxName, &dwMaxValue,
                                NULL, NULL);
    TCHAR chCMM[dwMaxName];
    ULONG cjCMM = sizeof(chCMM)/sizeof(chCMM[0]);
    DWORD dwType;
    TCHAR chCMMFile[dwMaxValue];
    ULONG cjCMMFile = sizeof(chCMMFile)/sizeof(chCMMFile[0]);

    if (dwErr != ERROR_SUCCESS)
        printf("Could not open ICMatcher registry key: %d\n", dwErr);

    if (dwErr == ERROR_SUCCESS)
        while (RegEnumValue(
                   chCMMFile,&cjCMMFile) == ERROR_SUCCESS)
            if (dwType == REG_SZ)
                printf("%d: %-80s - %-80s\n",dwNumCMM,chCMM,chCMMFile);
                printf("%d: error\n");

            cjCMM = sizeof(chCMM);
            cjCMMFile = sizeof(chCMMFile);