2016-10-30 15:03:30 -07:00
|
|
|
From b91e77db01f842164dd0ec593ad6bf433ad46c5e Mon Sep 17 00:00:00 2001
|
2014-07-26 14:49:56 -07:00
|
|
|
From: Dmitry Timoshkov <dmitry@baikal.ru>
|
|
|
|
Date: Mon, 17 Feb 2014 11:52:46 +0900
|
|
|
|
Subject: shell32: Implement SHCreateSessionKey.
|
|
|
|
|
|
|
|
This implementation is based on the Geoff Chappell description,
|
|
|
|
and it seems to be enough for the application I have here.
|
|
|
|
---
|
2016-10-30 15:03:30 -07:00
|
|
|
dlls/shell32/shellreg.c | 36 +++++++++++++++++++++++++++++++++---
|
|
|
|
dlls/shell32/tests/shellole.c | 8 ++++----
|
|
|
|
2 files changed, 37 insertions(+), 7 deletions(-)
|
2014-07-26 14:49:56 -07:00
|
|
|
|
|
|
|
diff --git a/dlls/shell32/shellreg.c b/dlls/shell32/shellreg.c
|
2016-10-30 15:03:30 -07:00
|
|
|
index 356ec4e..fff1b91 100644
|
2014-07-26 14:49:56 -07:00
|
|
|
--- a/dlls/shell32/shellreg.c
|
|
|
|
+++ b/dlls/shell32/shellreg.c
|
2016-10-30 15:03:30 -07:00
|
|
|
@@ -148,13 +148,43 @@ HRESULT WINAPI SHRegCloseKey (HKEY hkey)
|
2014-07-26 14:49:56 -07:00
|
|
|
return RegCloseKey( hkey );
|
|
|
|
}
|
2016-10-30 15:03:30 -07:00
|
|
|
|
2014-07-26 14:49:56 -07:00
|
|
|
+static const char session_reg_key[] = "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\SessionInfo\\";
|
|
|
|
+
|
|
|
|
+static BOOL WINAPI create_session_key(INIT_ONCE *once, void *param, void **context)
|
|
|
|
+{
|
|
|
|
+ static const char desktop_guid[] = "__wine_display_device_guid";
|
|
|
|
+ ATOM guid_atom;
|
|
|
|
+ HKEY hkey_session;
|
|
|
|
+ LPWSTR session_reg_str = param;
|
|
|
|
+
|
|
|
|
+ guid_atom = HandleToULong(GetPropA(GetDesktopWindow(), desktop_guid));
|
|
|
|
+ if (!guid_atom) return FALSE;
|
|
|
|
+
|
|
|
|
+ MultiByteToWideChar(CP_ACP, 0, session_reg_key, sizeof(session_reg_key), session_reg_str, sizeof(session_reg_key));
|
|
|
|
+
|
|
|
|
+ if (!GlobalGetAtomNameW(guid_atom, session_reg_str + sizeof(session_reg_key) - 1, 39))
|
|
|
|
+ return FALSE;
|
|
|
|
+
|
|
|
|
+ if (RegCreateKeyExW(HKEY_CURRENT_USER, session_reg_str, 0, NULL,
|
|
|
|
+ REG_OPTION_VOLATILE, KEY_WRITE, NULL, &hkey_session, NULL))
|
|
|
|
+ return FALSE;
|
|
|
|
+
|
|
|
|
+ RegCloseKey(hkey_session);
|
|
|
|
+ TRACE("session key %s\n", debugstr_w(session_reg_str));
|
|
|
|
+ return TRUE;
|
|
|
|
+}
|
|
|
|
+
|
2016-10-30 15:03:30 -07:00
|
|
|
/*************************************************************************
|
|
|
|
* SHCreateSessionKey [SHELL32.723]
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SHCreateSessionKey(REGSAM access, HKEY *hkey)
|
|
|
|
{
|
|
|
|
- FIXME("stub: %d %p\n", access, hkey);
|
|
|
|
- *hkey = NULL;
|
|
|
|
- return E_NOTIMPL;
|
2014-07-26 14:49:56 -07:00
|
|
|
+ static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
|
|
|
|
+ static WCHAR session_reg_str[sizeof(session_reg_key) + 39];
|
|
|
|
+
|
|
|
|
+ InitOnceExecuteOnce(&init_once, create_session_key, session_reg_str, NULL);
|
|
|
|
+
|
|
|
|
+ TRACE("using session key %s\n", debugstr_w(session_reg_str));
|
|
|
|
+ return RegOpenKeyExW(HKEY_CURRENT_USER, session_reg_str, 0, access, hkey);
|
2016-10-30 15:03:30 -07:00
|
|
|
}
|
2016-01-14 14:55:24 -08:00
|
|
|
diff --git a/dlls/shell32/tests/shellole.c b/dlls/shell32/tests/shellole.c
|
2016-10-30 15:03:30 -07:00
|
|
|
index be10733..72e0f31 100644
|
2016-01-14 14:55:24 -08:00
|
|
|
--- a/dlls/shell32/tests/shellole.c
|
|
|
|
+++ b/dlls/shell32/tests/shellole.c
|
2016-10-30 15:03:30 -07:00
|
|
|
@@ -877,14 +877,14 @@ static void test_SHCreateSessionKey(void)
|
2016-01-14 14:55:24 -08:00
|
|
|
hkey = (HKEY)0xdeadbeef;
|
|
|
|
hr = pSHCreateSessionKey(0, &hkey);
|
2016-10-30 15:03:30 -07:00
|
|
|
todo_wine ok(hr == E_ACCESSDENIED, "got 0x%08x\n", hr);
|
2016-01-14 14:55:24 -08:00
|
|
|
- ok(hkey == NULL, "got %p\n", hkey);
|
|
|
|
+ todo_wine ok(hkey == NULL, "got %p\n", hkey);
|
|
|
|
|
|
|
|
hr = pSHCreateSessionKey(KEY_READ, &hkey);
|
2016-10-30 15:03:30 -07:00
|
|
|
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
|
|
|
|
hr = pSHCreateSessionKey(KEY_READ, &hkey2);
|
|
|
|
- todo_wine ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
- todo_wine ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2);
|
|
|
|
+ ok(hr == S_OK, "got 0x%08x\n", hr);
|
|
|
|
+ ok(hkey != hkey2, "got %p, %p\n", hkey, hkey2);
|
|
|
|
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
RegCloseKey(hkey2);
|
2014-07-26 14:49:56 -07:00
|
|
|
--
|
2016-10-30 15:03:30 -07:00
|
|
|
2.9.0
|
2014-07-26 14:49:56 -07:00
|
|
|
|