Skip to content

Commit

Permalink
SetupHelper: Try to terminate ClassicShell Start Menu (to make upgrad…
Browse files Browse the repository at this point in the history
…e a bit easier)

During upgrade from ClassicShell we'll try to terminate
ClassicStartMenu.exe as well. So that installer won't complain about files
being in use.
  • Loading branch information
ge0rdi committed Aug 19, 2018
1 parent 45ab50e commit a167291
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions Src/Setup/SetupHelper/SetupHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@
#include <atlstr.h>
#include "ResourceHelper.h"

HINSTANCE g_hInstance;

///////////////////////////////////////////////////////////////////////////////

int ExitStartMenu( void )
int ExitStartMenu(const wchar_t* regPath, const wchar_t* exeName, const wchar_t* updaterClass)
{
HKEY hKey=NULL;
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,L"SOFTWARE\\OpenShell\\OpenShell",0,NULL,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_QUERY_VALUE|KEY_WOW64_64KEY,NULL,&hKey,NULL)==ERROR_SUCCESS)
if (RegCreateKeyEx(HKEY_LOCAL_MACHINE,regPath,0,NULL,REG_OPTION_NON_VOLATILE,KEY_READ|KEY_QUERY_VALUE|KEY_WOW64_64KEY,NULL,&hKey,NULL)==ERROR_SUCCESS)
{
DWORD type=0;
wchar_t path[_MAX_PATH];
Expand All @@ -25,7 +23,7 @@ int ExitStartMenu( void )
STARTUPINFO startupInfo={sizeof(startupInfo)};
PROCESS_INFORMATION processInfo;
memset(&processInfo,0,sizeof(processInfo));
wcscat_s(path,L"StartMenu.exe");
wcscat_s(path,exeName);
HANDLE h=CreateFile(path,GENERIC_READ,FILE_SHARE_READ|FILE_SHARE_WRITE,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL,NULL);
if (h!=INVALID_HANDLE_VALUE)
{
Expand All @@ -41,12 +39,23 @@ int ExitStartMenu( void )
}
RegCloseKey(hKey);
}
HWND updateOwner=FindWindow(L"OpenShellUpdate.COwnerWindow",NULL);
HWND updateOwner=FindWindow(updaterClass,NULL);
if (updateOwner)
PostMessage(updateOwner,WM_CLEAR,0,0);
return 0;
}

int ExitStartMenu()
{
// terminate Open-Shell Start Menu in clean way
ExitStartMenu(L"SOFTWARE\\OpenShell\\OpenShell", L"StartMenu.exe", L"OpenShellUpdate.COwnerWindow");

// try to terminate also ClassicShell Start Menu (to make upgrade a bit easier)
ExitStartMenu(L"SOFTWARE\\IvoSoft\\ClassicShell", L"ClassicStartMenu.exe", L"ClassicShellUpdate.COwnerWindow");

return 0;
}

int FixVersion( void )
{
HKEY hKey=NULL;
Expand Down Expand Up @@ -74,8 +83,6 @@ int WINAPI wWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpstrC
wchar_t *const *params=CommandLineToArgvW(lpstrCmdLine,&count);
if (!params) return 1;

g_hInstance=hInstance;

for (;count>0;count--,params++)
{
if (_wcsicmp(params[0],L"exitSM")==0)
Expand Down

0 comments on commit a167291

Please sign in to comment.