mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 09:34:43 +00:00
[EXPLORER] Check registry key for default shell (#7502)
Improves detection of Explorer being the default shell. - Check the "Software\Microsoft\Windows NT\CurrentVersion\Winlogon" key to see if Explorer is the default shell. - Use this check to determine whether to start the desktop and taskbar or only open a file browser window. JIRA issue CORE-19887
This commit is contained in:
parent
741535dc28
commit
df197bc424
1 changed files with 43 additions and 3 deletions
|
@ -87,6 +87,47 @@ HideMinimizedWindows(IN BOOL bHide)
|
|||
}
|
||||
#endif
|
||||
|
||||
static BOOL
|
||||
IsExplorerSystemShell()
|
||||
{
|
||||
BOOL bIsSystemShell = TRUE; // Assume we are the system shell by default.
|
||||
WCHAR szPath[MAX_PATH];
|
||||
|
||||
if (!GetModuleFileNameW(NULL, szPath, _countof(szPath)))
|
||||
return FALSE;
|
||||
|
||||
LPWSTR szExplorer = PathFindFileNameW(szPath);
|
||||
|
||||
HKEY hKeyWinlogon;
|
||||
if (RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"Software\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon",
|
||||
0, KEY_READ, &hKeyWinlogon) != ERROR_SUCCESS)
|
||||
{
|
||||
// No registry access.
|
||||
bIsSystemShell = TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
LSTATUS Status;
|
||||
DWORD dwType;
|
||||
WCHAR szShell[MAX_PATH];
|
||||
DWORD cbShell = sizeof(szShell);
|
||||
|
||||
// TODO: Add support for paths longer than MAX_PATH
|
||||
Status = RegQueryValueExW(hKeyWinlogon, L"Shell", 0, &dwType, (LPBYTE)szShell, &cbShell);
|
||||
if (Status == ERROR_SUCCESS)
|
||||
{
|
||||
if ((dwType == REG_SZ || dwType == REG_EXPAND_SZ) && StrStrI(szShell, szExplorer))
|
||||
bIsSystemShell = TRUE;
|
||||
else
|
||||
bIsSystemShell = FALSE;
|
||||
}
|
||||
|
||||
RegCloseKey(hKeyWinlogon);
|
||||
}
|
||||
|
||||
return bIsSystemShell;
|
||||
}
|
||||
|
||||
#if !WIN7_COMPAT_MODE
|
||||
static INT
|
||||
StartWithCommandLine(IN HINSTANCE hInstance)
|
||||
|
@ -212,15 +253,14 @@ _tWinMain(IN HINSTANCE hInstance,
|
|||
TRACE("Explorer starting... Command line: %S\n", lpCmdLine);
|
||||
|
||||
#if !WIN7_COMPAT_MODE
|
||||
if (GetShellWindow() == NULL)
|
||||
bExplorerIsShell = TRUE;
|
||||
bExplorerIsShell = (GetShellWindow() == NULL) && IsExplorerSystemShell();
|
||||
|
||||
if (!bExplorerIsShell)
|
||||
{
|
||||
return StartWithCommandLine(hInstance);
|
||||
}
|
||||
#else
|
||||
bExplorerIsShell = TRUE;
|
||||
bExplorerIsShell = IsExplorerSystemShell();
|
||||
#endif
|
||||
|
||||
return StartWithDesktop(hInstance);
|
||||
|
|
Loading…
Reference in a new issue