mirror of
https://github.com/reactos/reactos.git
synced 2025-07-27 20:32:18 +00:00
- Ensure that cursor schemes can be loaded from an unmodified Windows XP. The users "Schemes" key does not exist in this case.
- Also use the KEY_QUERY_VALUE access right to open registry keys. svn path=/trunk/; revision=26512
This commit is contained in:
parent
25e902187c
commit
638bc65d33
1 changed files with 54 additions and 52 deletions
|
@ -428,94 +428,96 @@ ButtonProc(IN HWND hwndDlg,
|
||||||
static BOOL
|
static BOOL
|
||||||
EnumerateCursorSchemes(HWND hwndDlg)
|
EnumerateCursorSchemes(HWND hwndDlg)
|
||||||
{
|
{
|
||||||
HKEY hCuKey;
|
HKEY hCursorKey;
|
||||||
HKEY hCuCursorKey;
|
|
||||||
DWORD dwIndex;
|
DWORD dwIndex;
|
||||||
TCHAR szValueName[MAX_PATH];
|
TCHAR szValueName[MAX_PATH];
|
||||||
DWORD dwValueName;
|
DWORD dwValueName;
|
||||||
TCHAR szSystemScheme[MAX_PATH];
|
TCHAR szSystemScheme[MAX_PATH];
|
||||||
TCHAR szValueData[2000];
|
TCHAR szValueData[2000];
|
||||||
DWORD dwValueData;
|
DWORD dwValueData;
|
||||||
LONG dwResult;
|
LONG lError;
|
||||||
HWND hDlgCtrl;
|
HWND hDlgCtrl;
|
||||||
LRESULT lResult;
|
LRESULT lResult;
|
||||||
BOOL ProcessedHKLM = FALSE;
|
|
||||||
TCHAR szCurrentScheme[MAX_PATH];
|
TCHAR szCurrentScheme[MAX_PATH];
|
||||||
DWORD dwCurrentScheme;
|
DWORD dwCurrentScheme;
|
||||||
INT nSchemeIndex;
|
INT nSchemeIndex;
|
||||||
INT i, nCount;
|
INT i, nCount;
|
||||||
LPTSTR p;
|
LPTSTR p;
|
||||||
|
|
||||||
if (RegOpenCurrentUser(KEY_READ, &hCuKey) != ERROR_SUCCESS)
|
|
||||||
return FALSE;
|
|
||||||
|
|
||||||
if (RegOpenKeyEx(hCuKey, _T("Control Panel\\Cursors\\Schemes"), 0, KEY_READ, &hCuCursorKey) != ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
RegCloseKey(hCuKey);
|
|
||||||
return FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
hDlgCtrl = GetDlgItem(hwndDlg, IDC_COMBO_CURSOR_SCHEME);
|
hDlgCtrl = GetDlgItem(hwndDlg, IDC_COMBO_CURSOR_SCHEME);
|
||||||
SendMessage(hDlgCtrl, CB_RESETCONTENT, 0, 0);
|
SendMessage(hDlgCtrl, CB_RESETCONTENT, 0, 0);
|
||||||
dwIndex = 0;
|
|
||||||
|
|
||||||
for (;;)
|
/* Read the users cursor schemes */
|
||||||
|
lError = RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Cursors\\Schemes"),
|
||||||
|
0, KEY_READ | KEY_QUERY_VALUE , &hCursorKey);
|
||||||
|
if (lError == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
dwValueName = sizeof(szValueName) / sizeof(TCHAR);
|
for (dwIndex = 0;; dwIndex++)
|
||||||
dwValueData = sizeof(szValueData) / sizeof(TCHAR);
|
|
||||||
dwResult = RegEnumValue(hCuCursorKey, dwIndex, szValueName, &dwValueName, NULL, NULL, (LPBYTE)szValueData, &dwValueData);
|
|
||||||
|
|
||||||
if (dwResult == ERROR_NO_MORE_ITEMS)
|
|
||||||
{
|
{
|
||||||
if (!ProcessedHKLM)
|
dwValueName = sizeof(szValueName) / sizeof(TCHAR);
|
||||||
|
dwValueData = sizeof(szValueData) / sizeof(TCHAR);
|
||||||
|
lError = RegEnumValue(hCursorKey, dwIndex, szValueName, &dwValueName,
|
||||||
|
NULL, NULL, (LPBYTE)szValueData, &dwValueData);
|
||||||
|
if (lError == ERROR_NO_MORE_ITEMS)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (_tcslen(szValueData) > 0)
|
||||||
{
|
{
|
||||||
RegCloseKey(hCuCursorKey);
|
LPTSTR copy = _tcsdup(szValueData);
|
||||||
dwResult = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
|
||||||
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cursors\\Schemes"),
|
lResult = SendMessage(hDlgCtrl, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValueName);
|
||||||
0, KEY_READ, &hCuCursorKey);
|
SendMessage(hDlgCtrl, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)copy);
|
||||||
if (dwResult == ERROR_SUCCESS)
|
|
||||||
{
|
|
||||||
dwIndex = 0;
|
|
||||||
ProcessedHKLM = TRUE;
|
|
||||||
LoadString(hApplet, IDS_SYSTEM_SCHEME, szSystemScheme, MAX_PATH);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_tcslen(szValueData) > 0)
|
RegCloseKey(hCursorKey);
|
||||||
{
|
|
||||||
TCHAR * copy = _tcsdup(szValueData);
|
|
||||||
if (ProcessedHKLM)
|
|
||||||
{
|
|
||||||
_tcscat(szValueName, TEXT(" "));
|
|
||||||
_tcscat(szValueName, szSystemScheme);
|
|
||||||
}
|
|
||||||
lResult = SendMessage(hDlgCtrl, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValueName);
|
|
||||||
SendMessage(hDlgCtrl, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)copy);
|
|
||||||
}
|
|
||||||
|
|
||||||
dwIndex++;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
RegCloseKey(hCuCursorKey);
|
/* Read the system cursor schemes */
|
||||||
RegCloseKey(hCuKey);
|
lError = RegOpenKeyEx(HKEY_LOCAL_MACHINE,
|
||||||
|
_T("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Control Panel\\Cursors\\Schemes"),
|
||||||
|
0, KEY_READ | KEY_QUERY_VALUE , &hCursorKey);
|
||||||
|
if (lError == ERROR_SUCCESS)
|
||||||
|
{
|
||||||
|
LoadString(hApplet, IDS_SYSTEM_SCHEME, szSystemScheme, MAX_PATH);
|
||||||
|
|
||||||
|
for (dwIndex = 0;; dwIndex++)
|
||||||
|
{
|
||||||
|
dwValueName = sizeof(szValueName) / sizeof(TCHAR);
|
||||||
|
dwValueData = sizeof(szValueData) / sizeof(TCHAR);
|
||||||
|
lError = RegEnumValue(hCursorKey, dwIndex, szValueName, &dwValueName,
|
||||||
|
NULL, NULL, (LPBYTE)szValueData, &dwValueData);
|
||||||
|
if (lError == ERROR_NO_MORE_ITEMS)
|
||||||
|
break;
|
||||||
|
|
||||||
|
if (_tcslen(szValueData) > 0)
|
||||||
|
{
|
||||||
|
LPTSTR copy = _tcsdup(szValueData);
|
||||||
|
_tcscat(szValueName, TEXT(" "));
|
||||||
|
_tcscat(szValueName, szSystemScheme);
|
||||||
|
|
||||||
|
lResult = SendMessage(hDlgCtrl, CB_ADDSTRING, (WPARAM)0, (LPARAM)szValueName);
|
||||||
|
SendMessage(hDlgCtrl, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)copy);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
RegCloseKey(hCursorKey);
|
||||||
|
}
|
||||||
|
|
||||||
/* Add the "(none)" entry */
|
/* Add the "(none)" entry */
|
||||||
LoadString(hApplet, IDS_NONE, szSystemScheme, MAX_PATH);
|
LoadString(hApplet, IDS_NONE, szSystemScheme, MAX_PATH);
|
||||||
lResult = SendMessage(hDlgCtrl, CB_ADDSTRING, (WPARAM)0, (LPARAM)szSystemScheme);
|
lResult = SendMessage(hDlgCtrl, CB_ADDSTRING, (WPARAM)0, (LPARAM)szSystemScheme);
|
||||||
SendMessage(hDlgCtrl, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)NULL);
|
SendMessage(hDlgCtrl, CB_SETITEMDATA, (WPARAM)lResult, (LPARAM)NULL);
|
||||||
|
|
||||||
|
|
||||||
/* Get the name of the current cursor scheme */
|
/* Get the name of the current cursor scheme */
|
||||||
szCurrentScheme[0] = 0;
|
szCurrentScheme[0] = 0;
|
||||||
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Cursors"), 0, KEY_READ, &hCuCursorKey) == ERROR_SUCCESS)
|
if (RegOpenKeyEx(HKEY_CURRENT_USER, _T("Control Panel\\Cursors"), 0, KEY_READ | KEY_QUERY_VALUE, &hCursorKey) == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
dwCurrentScheme = sizeof(szCurrentScheme) / sizeof(TCHAR);
|
dwCurrentScheme = sizeof(szCurrentScheme) / sizeof(TCHAR);
|
||||||
if (RegQueryValueEx(hCuCursorKey, NULL, NULL, NULL, (LPBYTE)szCurrentScheme, &dwCurrentScheme))
|
if (RegQueryValueEx(hCursorKey, NULL, NULL, NULL, (LPBYTE)szCurrentScheme, &dwCurrentScheme))
|
||||||
szCurrentScheme[0] = 0;
|
szCurrentScheme[0] = 0;
|
||||||
RegCloseKey(hCuCursorKey);
|
|
||||||
|
RegCloseKey(hCursorKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search for the matching entry in the cursor scheme list */
|
/* Search for the matching entry in the cursor scheme list */
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue