#include <Windows.h> #include <Icm.h> #include <iostream> #include <string> #pragma comment(lib,"Mscms.lib") #define MAX_PATH 1024 BOOL flag = 0; int main() { WCHAR* szDisplayDeviceName = NULL; WCHAR szPath[MAX_PATH]; memset(szPath, 0, 1024); DISPLAY_DEVICE dd; dd.cb = sizeof(dd); if (flag = EnumDisplayDevices(L"\\.\DISPLAY1", 0, &dd, EDD_GET_DEVICE_INTERFACE_NAME)) { if (flag = WcsGetDefaultColorProfile(WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER, dd.DeviceKey, CPT_ICC, CPST_PERCEPTUAL, 0, // dwProfileID -- doesn't seem to matter what value you use here MAX_PATH * sizeof(WCHAR), szPath)) { PROFILE profile; profile.cbDataSize = (DWORD)(wcslen(szPath) + 1) * sizeof(WCHAR); profile.dwType = PROFILE_FILENAME; profile.pProfileData = (PVOID)szPath; HPROFILE hProfile = OpenColorProfile(&profile, PROFILE_READ, FILE_SHARE_READ, OPEN_EXISTING); // now do something with the profile } } LPWSTR buffer; ENUMTYPEW pe = { 0 }; pe.dwSize = sizeof(pe); pe.dwVersion = ENUM_TYPE_VERSION; pe.dwFields = ET_DEVICENAME; pe.dwDeviceClass = CLASS_MONITOR; pe.pDeviceName = dd.DeviceKey; DWORD p = 0; DWORD size = 0; BOOL ret = EnumColorProfilesW(NULL, &pe, NULL, &size, &p); buffer = (LPWSTR)malloc(size); ret = EnumColorProfilesW(NULL, &pe, (BYTE*)buffer, &size, &p); LPWSTR temp = buffer; for (int i = 0; i < p; i++) { wprintf(L"%s ", temp); printf("without null character: %zu ", wcslen(temp)); temp += wcslen(temp) + 1; } flag = WcsSetDefaultColorProfile(WCS_PROFILE_MANAGEMENT_SCOPE_CURRENT_USER, dd.DeviceKey, CPT_ICC, CPST_PERCEPTUAL, 0, // dwProfileID -- doesn't seem to matter what value you use here buffer); free(buffer); return 1; }
这是列举出本机上的所有icm配置文件