gdi32: Return registered monitor profile from GetICMProfile.

oldstable
Hans Leidekker 2008-02-27 15:13:44 +01:00 committed by Alexandre Julliard
parent eaea28e5d8
commit d6bb9e76b3
1 changed files with 25 additions and 9 deletions

View File

@ -28,6 +28,7 @@
#include "winbase.h"
#include "wingdi.h"
#include "winnls.h"
#include "winreg.h"
#include "wine/debug.h"
#include "wine/unicode.h"
@ -96,20 +97,37 @@ BOOL WINAPI GetICMProfileA(HDC hdc, LPDWORD size, LPSTR filename)
*/
BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
{
HKEY hkey;
DWORD required;
WCHAR systemdir[MAX_PATH];
static const WCHAR profile[] =
WCHAR profile[MAX_PATH], fullname[MAX_PATH];
static const WCHAR path[] =
{'\\','s','p','o','o','l','\\','d','r','i','v','e','r','s',
'\\','c','o','l','o','r','\\','s','R','G','B',' ','C','o','l','o','r',' ',
'S','p','a','c','e',' ','P','r','o','f','i','l','e','.','i','c','m',0};
'\\','c','o','l','o','r','\\',0};
static const WCHAR srgb[] =
{'s','R','G','B',' ','C','o','l','o','r',' ','S','p','a','c','e',' ',
'P','r','o','f','i','l','e','.','i','c','m',0};
static const WCHAR mntr[] =
{'S','o','f','t','w','a','r','e','\\','M','i','c','r','o','s','o','f','t','\\',
'W','i','n','d','o','w','s',' ','N','T','\\','C','u','r','r','e','n','t',
'V','e','r','s','i','o','n','\\','I','C','M','\\','m','n','t','r',0};
TRACE("%p, %p, %p\n", hdc, size, filename);
if (!hdc || !size) return FALSE;
required = GetSystemDirectoryW(systemdir, MAX_PATH);
required += sizeof(profile) / sizeof(WCHAR);
strcpyW(profile, srgb);
if (!RegCreateKeyExW(HKEY_LOCAL_MACHINE, mntr, 0, NULL, 0, KEY_ALL_ACCESS, NULL, &hkey, NULL))
{
DWORD size = sizeof(profile) / sizeof(WCHAR);
/* FIXME handle multiple values */
RegEnumValueW(hkey, 0, profile, &size, NULL, NULL, NULL, NULL);
RegCloseKey(hkey);
}
GetSystemDirectoryW(fullname, MAX_PATH);
strcatW(fullname, path);
strcatW(fullname, profile);
required = strlenW(fullname) + 1;
if (*size < required)
{
*size = required;
@ -118,9 +136,7 @@ BOOL WINAPI GetICMProfileW(HDC hdc, LPDWORD size, LPWSTR filename)
}
if (filename)
{
strcpyW(filename, systemdir);
strcatW(filename, profile);
strcpyW(filename, fullname);
if (GetFileAttributesW(filename) == INVALID_FILE_ATTRIBUTES)
WARN("color profile not found\n");
}