mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 18:15:11 +00:00
[EXPLORER] Execute RunOnce[Ex] before desktop is created (#7143)
CORE-19501
This commit is contained in:
parent
28cb0995e6
commit
738c8fc27c
3 changed files with 35 additions and 14 deletions
|
@ -154,6 +154,8 @@ StartWithDesktop(IN HINSTANCE hInstance)
|
||||||
buttons to work right) */
|
buttons to work right) */
|
||||||
HideMinimizedWindows(TRUE);
|
HideMinimizedWindows(TRUE);
|
||||||
|
|
||||||
|
ProcessRunOnceItems(); // Must be executed before the desktop is created
|
||||||
|
|
||||||
HANDLE hShellDesktop = NULL;
|
HANDLE hShellDesktop = NULL;
|
||||||
if (Tray != NULL)
|
if (Tray != NULL)
|
||||||
hShellDesktop = DesktopCreateWindow(Tray);
|
hShellDesktop = DesktopCreateWindow(Tray);
|
||||||
|
@ -167,6 +169,7 @@ StartWithDesktop(IN HINSTANCE hInstance)
|
||||||
ProcessStartupItems();
|
ProcessStartupItems();
|
||||||
DoFinishStartupItems();
|
DoFinishStartupItems();
|
||||||
}
|
}
|
||||||
|
ReleaseStartupMutex(); // For ProcessRunOnceItems
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (Tray != NULL)
|
if (Tray != NULL)
|
||||||
|
|
|
@ -252,9 +252,12 @@ HRESULT ShutdownShellServices(HDPA hdpa);
|
||||||
* startup.cpp
|
* startup.cpp
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
VOID ReleaseStartupMutex();
|
||||||
|
VOID ProcessRunOnceItems();
|
||||||
BOOL DoStartStartupItems(ITrayWindow *Tray);
|
BOOL DoStartStartupItems(ITrayWindow *Tray);
|
||||||
INT ProcessStartupItems(VOID);
|
INT ProcessStartupItems(BOOL bRunOnce);
|
||||||
BOOL DoFinishStartupItems(VOID);
|
static inline INT ProcessStartupItems() { return ProcessStartupItems(FALSE); }
|
||||||
|
static inline VOID DoFinishStartupItems() { ReleaseStartupMutex(); }
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* trayprop.h
|
* trayprop.h
|
||||||
|
|
|
@ -450,7 +450,7 @@ AutoStartupApplications(INT nCSIDL_Folder)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
INT ProcessStartupItems(VOID)
|
INT ProcessStartupItems(BOOL bRunOnce)
|
||||||
{
|
{
|
||||||
/* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */
|
/* TODO: ProcessRunKeys already checks SM_CLEANBOOT -- items prefixed with * should probably run even in safe mode */
|
||||||
BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */
|
BOOL bNormalBoot = GetSystemMetrics(SM_CLEANBOOT) == 0; /* Perform the operations that are performed every boot */
|
||||||
|
@ -478,11 +478,16 @@ INT ProcessStartupItems(VOID)
|
||||||
*/
|
*/
|
||||||
res = TRUE;
|
res = TRUE;
|
||||||
|
|
||||||
if (res && bNormalBoot)
|
if (bRunOnce)
|
||||||
ProcessRunOnceEx(HKEY_LOCAL_MACHINE);
|
{
|
||||||
|
if (res && bNormalBoot)
|
||||||
|
ProcessRunOnceEx(HKEY_LOCAL_MACHINE);
|
||||||
|
|
||||||
if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0))
|
if (res && (SHRestricted(REST_NOLOCALMACHINERUNONCE) == 0))
|
||||||
res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE);
|
res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"RunOnce", TRUE, TRUE);
|
||||||
|
|
||||||
|
return !res;
|
||||||
|
}
|
||||||
|
|
||||||
if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0))
|
if (res && bNormalBoot && (SHRestricted(REST_NOLOCALMACHINERUN) == 0))
|
||||||
res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE);
|
res = ProcessRunKeys(HKEY_LOCAL_MACHINE, L"Run", FALSE, FALSE);
|
||||||
|
@ -505,7 +510,7 @@ INT ProcessStartupItems(VOID)
|
||||||
return res ? 0 : 101;
|
return res ? 0 : 101;
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DoFinishStartupItems(VOID)
|
VOID ReleaseStartupMutex()
|
||||||
{
|
{
|
||||||
if (s_hStartupMutex)
|
if (s_hStartupMutex)
|
||||||
{
|
{
|
||||||
|
@ -513,13 +518,10 @@ BOOL DoFinishStartupItems(VOID)
|
||||||
CloseHandle(s_hStartupMutex);
|
CloseHandle(s_hStartupMutex);
|
||||||
s_hStartupMutex = NULL;
|
s_hStartupMutex = NULL;
|
||||||
}
|
}
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL DoStartStartupItems(ITrayWindow *Tray)
|
static BOOL InitializeStartupMutex()
|
||||||
{
|
{
|
||||||
DWORD dwWait;
|
|
||||||
|
|
||||||
if (!bExplorerIsShell)
|
if (!bExplorerIsShell)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
|
@ -532,15 +534,22 @@ BOOL DoStartStartupItems(ITrayWindow *Tray)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
dwWait = WaitForSingleObject(s_hStartupMutex, INFINITE);
|
DWORD dwWait = WaitForSingleObject(s_hStartupMutex, INFINITE);
|
||||||
TRACE("dwWait: 0x%08lX\n", dwWait);
|
TRACE("dwWait: 0x%08lX\n", dwWait);
|
||||||
if (dwWait != WAIT_OBJECT_0)
|
if (dwWait != WAIT_OBJECT_0)
|
||||||
{
|
{
|
||||||
TRACE("LastError: %ld\n", GetLastError());
|
TRACE("LastError: %ld\n", GetLastError());
|
||||||
|
|
||||||
DoFinishStartupItems();
|
ReleaseStartupMutex();
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
BOOL DoStartStartupItems(ITrayWindow *Tray)
|
||||||
|
{
|
||||||
|
if (!bExplorerIsShell || !InitializeStartupMutex())
|
||||||
|
return FALSE;
|
||||||
|
|
||||||
const DWORD dwWaitTotal = 3000; // in milliseconds
|
const DWORD dwWaitTotal = 3000; // in milliseconds
|
||||||
DWORD dwTick = GetTickCount();
|
DWORD dwTick = GetTickCount();
|
||||||
|
@ -575,3 +584,9 @@ BOOL DoStartStartupItems(ITrayWindow *Tray)
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
VOID ProcessRunOnceItems()
|
||||||
|
{
|
||||||
|
if (bExplorerIsShell && IsUserAnAdmin() && InitializeStartupMutex())
|
||||||
|
ProcessStartupItems(TRUE);
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue