From e7c84f82c730bddb7450dc56065aab11b93ffd30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mathias=20K=C3=BCsel?= Date: Tue, 27 Jan 2015 16:01:23 +0100 Subject: [PATCH] win,msi: broadcast WM_SETTINGCHANGE after install Backport 668bde8ac0d16382cbc98c904d8b5f55fd9fd9f0 from io.js. Original commit message follows: In theory the msi should broadcast a 'WM_SETTINGCHANGE' message to all windows after modifying the PATH environment variable. This ensures that the new PATH is visible to other processes without restarting windows (although it's still necessary to close and reopen active console windows). Unfortunately, the broadcast doesn't always happen, for unknown reasons. That's why this patch adds a custom action that unconditionally broadcasts a WM_SETTINGCHANGE message. Bug: https://github.com/iojs/io.js/issues/603 PR: https://github.com/iojs/io.js/pull/613 Reviewed-by: Bert Belder (cherry picked from commit 668bde8ac0d16382cbc98c904d8b5f55fd9fd9f0) --Node.js commmit metadata-- PR-URL: https://github.com/joyent/node/pull/25100 Reviewed-By: Julien Gilli Fixes: https://github.com/joyent/node/issues/4356 --- .gitignore | 1 + tools/msvs/msi/custom_actions.c | 42 ++++++ tools/msvs/msi/custom_actions.def | 4 + tools/msvs/msi/custom_actions.vcxproj | 181 ++++++++++++++++++++++++++ tools/msvs/msi/nodemsi.sln | 10 ++ tools/msvs/msi/nodemsi.wixproj | 10 ++ tools/msvs/msi/product.wxs | 10 ++ 7 files changed, 258 insertions(+) create mode 100644 tools/msvs/msi/custom_actions.c create mode 100644 tools/msvs/msi/custom_actions.def create mode 100644 tools/msvs/msi/custom_actions.vcxproj diff --git a/.gitignore b/.gitignore index 672d08ac3dc6..93e41e5753d3 100644 --- a/.gitignore +++ b/.gitignore @@ -28,6 +28,7 @@ Release/ *.suo *.vcproj *.vcxproj +!custom_actions.vcxproj *.vcxproj.user *.vcxproj.filters UpgradeLog*.XML diff --git a/tools/msvs/msi/custom_actions.c b/tools/msvs/msi/custom_actions.c new file mode 100644 index 000000000000..5e7d617f3879 --- /dev/null +++ b/tools/msvs/msi/custom_actions.c @@ -0,0 +1,42 @@ + +#define WIN32_LEAN_AND_MEAN + +#include +#include +#include + + +UINT WINAPI BroadcastEnvironmentUpdate(MSIHANDLE hInstall) { + HRESULT hr = S_OK; + UINT er = ERROR_SUCCESS; + + hr = WcaInitialize(hInstall, "BroadcastEnvironmentUpdate"); + ExitOnFailure(hr, "Failed to initialize"); + + SendMessageTimeoutW(HWND_BROADCAST, + WM_SETTINGCHANGE, + 0, + (LPARAM) L"Environment", + SMTO_ABORTIFHUNG, + 5000, + NULL); + +LExit: + er = SUCCEEDED(hr) ? ERROR_SUCCESS : ERROR_INSTALL_FAILURE; + return WcaFinalize(er); +} + + +BOOL WINAPI DllMain(HINSTANCE hInst, ULONG ulReason, VOID* dummy) { + switch (ulReason) { + case DLL_PROCESS_ATTACH: + WcaGlobalInitialize(hInst); + break; + + case DLL_PROCESS_DETACH: + WcaGlobalFinalize(); + break; + } + + return TRUE; +} diff --git a/tools/msvs/msi/custom_actions.def b/tools/msvs/msi/custom_actions.def new file mode 100644 index 000000000000..29e0933e379a --- /dev/null +++ b/tools/msvs/msi/custom_actions.def @@ -0,0 +1,4 @@ +LIBRARY "custom_actions" + +EXPORTS +BroadcastEnvironmentUpdate \ No newline at end of file diff --git a/tools/msvs/msi/custom_actions.vcxproj b/tools/msvs/msi/custom_actions.vcxproj new file mode 100644 index 000000000000..e014a6981f5f --- /dev/null +++ b/tools/msvs/msi/custom_actions.vcxproj @@ -0,0 +1,181 @@ + + + + + Debug + Win32 + + + Debug + x64 + + + Release + Win32 + + + Release + x64 + + + + {B70585F8-DAB7-40FA-9904-13CF53A73A06} + BroadcastPathUpdateCustomAction + Win32Proj + custom_actions + + + + DynamicLibrary + v120 + Unicode + true + + + DynamicLibrary + v120 + Unicode + true + + + DynamicLibrary + v120 + Unicode + + + DynamicLibrary + v120 + Unicode + + + + + + + + + + + + + + + + + + + <_ProjectFileVersion>12.0.30501.0 + + + true + + + true + + + false + + + false + + + + Disabled + $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + ProgramDatabase + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + + + + + Disabled + $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + WIN32;_DEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + EnableFastChecks + MultiThreadedDebug + NotUsing + Level3 + ProgramDatabase + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + + + + + MaxSpeed + true + $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + NotUsing + + + + + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WIX)sdk\VS2013\lib\x86;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + true + true + + + + + MaxSpeed + true + $(WIX)sdk\VS2013\inc;%(AdditionalIncludeDirectories) + WIN32;NDEBUG;_WINDOWS;_USRDLL;%(PreprocessorDefinitions) + MultiThreaded + true + Level3 + ProgramDatabase + NotUsing + + + + + + + msi.lib;dutil.lib;wcautil.lib;version.lib;%(AdditionalDependencies) + $(WIX)sdk\VS2013\lib\x64;%(AdditionalLibraryDirectories) + custom_actions.def + true + Windows + true + true + + + + + + + + + + + + + \ No newline at end of file diff --git a/tools/msvs/msi/nodemsi.sln b/tools/msvs/msi/nodemsi.sln index f95b00f879ce..9a3bab3f5cb4 100644 --- a/tools/msvs/msi/nodemsi.sln +++ b/tools/msvs/msi/nodemsi.sln @@ -3,6 +3,8 @@ Microsoft Visual Studio Solution File, Format Version 11.00 # Visual Studio 2010 Project("{930C7802-8A8C-48F9-8165-68863BCCD9DD}") = "nodemsi", "nodemsi.wixproj", "{1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}" EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "custom_actions", "custom_actions.vcxproj", "{B70585F8-DAB7-40FA-9904-13CF53A73A06}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 @@ -19,6 +21,14 @@ Global {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x64.Build.0 = Release|x64 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.ActiveCfg = Release|x86 {1D808FF0-B5A9-4BE9-859D-B334B6F48BE2}.Release|x86.Build.0 = Release|x86 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x64.ActiveCfg = Debug|x64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x64.Build.0 = Debug|x64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x86.ActiveCfg = Debug|Win32 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Debug|x86.Build.0 = Debug|Win32 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x64.ActiveCfg = Release|x64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x64.Build.0 = Release|x64 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x86.ActiveCfg = Release|Win32 + {B70585F8-DAB7-40FA-9904-13CF53A73A06}.Release|x86.Build.0 = Release|Win32 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/tools/msvs/msi/nodemsi.wixproj b/tools/msvs/msi/nodemsi.wixproj index 1059bccb22d6..8d17a6cfb4a7 100644 --- a/tools/msvs/msi/nodemsi.wixproj +++ b/tools/msvs/msi/nodemsi.wixproj @@ -56,6 +56,16 @@ + + + custom_actions + {b70585f8-dab7-40fa-9904-13cf53a73a06} + True + True + Binaries;Content;Satellites + INSTALLFOLDER + + diff --git a/tools/msvs/msi/product.wxs b/tools/msvs/msi/product.wxs index 1d674aaa0686..e7c55edd9afa 100755 --- a/tools/msvs/msi/product.wxs +++ b/tools/msvs/msi/product.wxs @@ -237,7 +237,17 @@ + + + + +