Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion docs/manual.txt
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,8 @@ Contents:
key combination: CTRL+ALT+F1 that is, press and hold the CTRL key and the ALT
key then depress the F1 key and release all three. A popup menu will appear at
your mouse cursor location. This menu can be used recover from a broken
configuration.
configuration. Note that launching Explorer might not always work if there is
already an Explorer file manager window open.

A) LiteStep Structure
---------------------
Expand Down
19 changes: 19 additions & 0 deletions litestep/RecoveryMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
#define ID_TERMINATE 3
#define ID_RUN 4
#define ID_SHUTDOWN 5
#define ID_EXPLORER 6
#define ID_ABOUT 7

const TCHAR szRecoveryMenuWndClass[] = _T("RecoveryMenuWndClass");

Expand All @@ -56,8 +58,10 @@ rgMenuCommands[] = \
{ IDS_LITESTEP_RECYCLELS, ID_RECYCLE, "Re&cycle LiteStep" }
,{ IDS_LITESTEP_QUITLS, ID_QUIT, "&Quit LiteStep" }
,{ IDS_LITESTEP_TERMINATELS, ID_TERMINATE, "Forcibly &Terminate LiteStep" }
,{ IDS_LITESTEP_ABOUTLS, ID_ABOUT, "&About LiteStep" }
,{ 0, -1, "" }
,{ IDS_LITESTEP_RUN, ID_RUN, "&Run..." }
,{ IDS_LITESTEP_EXPLORER, ID_EXPLORER, "&Start Explorer as shell" }
,{ 0, -1, "" }
,{ IDS_LITESTEP_SHUTDOWNWIN, ID_SHUTDOWN, "Sh&utdown Windows..." }
};
Expand Down Expand Up @@ -344,6 +348,21 @@ void RecoveryMenu::HandleMenuCommand(int nCommand) const
PostMessage(GetLitestepWnd(), LM_RECYCLE, LR_QUIT, 0);
}
break;

case ID_ABOUT:
{
// ditto
LMBANGCOMMAND lmbc = {sizeof(LMBANGCOMMAND), NULL, "!about", NULL};
PostMessage(GetLitestepWnd(), LM_BANGCOMMAND, 0, (LPARAM)&lmbc);
}
break;

case ID_EXPLORER:
{
// ditto
PostMessage(GetLitestepWnd(), LM_RECYCLE, LR_EXPLORER, 0);
}
break;

case ID_TERMINATE:
{
Expand Down
89 changes: 53 additions & 36 deletions litestep/WinMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,59 +277,76 @@ int WINAPI _tWinMain(HINSTANCE hInst, HINSTANCE, LPTSTR lpCmdLine, int)
wStartFlags &= ~LSF_RUN_STARTUPAPPS;
}

if (wStartFlags & LSF_RUN_EXPLORER)
bool bLoop;
do
{
//
// Mode 2: (Try to) start Explorer
//
if (StartExplorerShell(EXPLORER_WAIT_TIMEOUT))
{
// Explorer started as shell, no need try LiteStep as well
wStartFlags &= ~LSF_RUN_LITESTEP;
}
else
{
wStartFlags &= ~LSF_RUN_EXPLORER;
}
}

if (wStartFlags & LSF_RUN_LITESTEP)
{
HANDLE hMutex = NULL;
// Loop back here if explorer is requested as the shell
// while LiteStep is already running

if (IsOtherInstanceRunning(&hMutex))
if (wStartFlags & LSF_RUN_EXPLORER)
{
//
// Mode 3a: Other LiteStep instance already running
// Mode 2: (Try to) start Explorer
//
RESOURCE_STR(hInst, IDS_LITESTEP_ERROR1,
"A previous instance of LiteStep was detected.\n"
"Are you sure you want to continue?");

// Can show a MessageBox here since the other instance
// should have closed the welcome screen already
INT idConfirm = RESOURCE_MSGBOX_F(
"LiteStep", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2);

if (idConfirm == IDNO)
if (StartExplorerShell(EXPLORER_WAIT_TIMEOUT))
{
// Explorer started as shell, no need try LiteStep as well
wStartFlags &= ~LSF_RUN_LITESTEP;
}
else
{
wStartFlags &= ~LSF_RUN_EXPLORER;
}
}

if (wStartFlags & LSF_RUN_LITESTEP)
{
//
// Mode 3b: Start the shell!
//
nReturn = StartLitestep(hInst, wStartFlags, szAltConfigFile);
HANDLE hMutex = NULL;

if (IsOtherInstanceRunning(&hMutex))
{
//
// Mode 3a: Other LiteStep instance already running
//
RESOURCE_STR(hInst, IDS_LITESTEP_ERROR1,
"A previous instance of LiteStep was detected.\n"
"Are you sure you want to continue?");

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

// Can show a MessageBox here since the other instance
// should have closed the welcome screen already
INT idConfirm = RESOURCE_MSGBOX_F(
"LiteStep", MB_ICONINFORMATION | MB_YESNO | MB_DEFBUTTON2);

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

if (idConfirm == IDNO)
{
wStartFlags &= ~LSF_RUN_LITESTEP;
}
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

if (wStartFlags & LSF_RUN_LITESTEP)
{
//
// Mode 3b: Start the shell!
//
nReturn = StartLitestep(hInst, wStartFlags, szAltConfigFile);
}

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

whitespace

if (hMutex)
{
CloseHandle(hMutex);
}
}

if (hMutex)
bLoop = false;

if ((nReturn == LRV_EXPLORER_START) && (wStartFlags & LSF_RUN_LITESTEP))
{
CloseHandle(hMutex);
// User wants Explorer as the shell anyway
wStartFlags |= LSF_RUN_EXPLORER;
bLoop = true;
}
}
while (bLoop);
}

return nReturn;
Expand Down
12 changes: 9 additions & 3 deletions litestep/litestep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile)
if (FAILED(GetAppPath(szAppPath, COUNTOF(szAppPath))))
{
// something really crappy is going on.
return -1;
return LRV_NO_APP_PATH;
}

if (wStartFlags & LSF_ALTERNATE_CONFIG)
Expand Down Expand Up @@ -195,7 +195,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile)

RESOURCE_MSGBOX_F("LiteStep", MB_ICONERROR);

return 2;
return LRV_NO_STEP;
}

// Initialize the LSAPI. Note: The LSAPI controls the bang and settings
Expand All @@ -205,7 +205,7 @@ int StartLitestep(HINSTANCE hInst, WORD wStartFlags, LPCTSTR pszAltConfigFile)
RESOURCE_MSGBOX(hInst, IDS_LSAPI_INIT_ERROR,
"Failed to initialize the LiteStep API.", "LiteStep");

return 3;
return LRV_LSAPI_FAIL;
}

// All child processes get this variable
Expand Down Expand Up @@ -906,6 +906,12 @@ LRESULT CLiteStep::InternalWndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM l
PostQuitMessage(0);
}
break;

case LR_EXPLORER:
{
PostQuitMessage(4);
}
break;

default: // wParam == LR_MSSHUTDOWN
{
Expand Down
2 changes: 2 additions & 0 deletions litestep/litestep.rc
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ BEGIN
IDS_LITESTEP_RUN "&Run..."
IDS_LITESTEP_SHUTDOWNWIN "Sh&utdown Windows..."
IDS_MODULEQUIT_ERROR "Exception while quitting module."
IDS_LITESTEP_ABOUTLS "&About LiteStep"
IDS_LITESTEP_EXPLORER "&Start Explorer as shell"
END

STRINGTABLE
Expand Down
2 changes: 2 additions & 0 deletions litestep/resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
#define IDS_MATHEXCEPTION 25
#define IDS_LSAPI_INIT_ERROR 26
#define IDS_LITESTEP_INIT_ERROR 27
#define IDS_LITESTEP_ABOUTLS 28
#define IDS_LITESTEP_EXPLORER 29
#define IDI_LS 101
#define IDB_LS 102
#define IDD_ABOUTBOX 103
Expand Down
1 change: 1 addition & 0 deletions lsapi/lsapidefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ typedef struct LSDESKTOPINFO
#define LR_LOGOFF 1
#define LR_QUIT 2
#define LR_MSSHUTDOWN 3
#define LR_EXPLORER 4


//-----------------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion utility/shellhlp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ void LSShutdownDialog(HWND hWnd)
(GetAsyncKeyState(VK_CONTROL) & 0x8000) &&
(GetAsyncKeyState(VK_MENU) & 0x8000))
{
PostQuitMessage(1);
PostQuitMessage(LRV_SHUTDOWN_DLG);
}
}
}
Expand Down
11 changes: 11 additions & 0 deletions utility/shellhlp.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,17 @@ HANDLE LSActivateActCtxForDll(LPCTSTR pszDll, PULONG_PTR pulCookie);
HANDLE LSActivateActCtxForClsid(REFCLSID rclsid, PULONG_PTR pulCookie);
void LSDeactivateActCtx(HANDLE hActCtx, ULONG_PTR* pulCookie);

//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
// Litestep Return Values (LRV)
//
#define LRV_NO_APP_PATH -1
#define LRV_OK 0 // is also S_OK from WinError
#define LRV_SHUTDOWN_DLG 1
#define LRV_NO_STEP 2
#define LRV_LSAPI_FAIL 3
#define LRV_EXPLORER_START 4


//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
//
Expand Down