aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 04:12:59 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 04:12:59 +0300
commit71fc6146725072f1b62e493a481ad18e307bd074 (patch)
treeb8b62e3c40ad48fe08931031d6bec267a5db3e3e /src
parentcode style (diff)
downloadwindows-env-71fc6146725072f1b62e493a481ad18e307bd074.tar.gz
windows-env-71fc6146725072f1b62e493a481ad18e307bd074.zip
bugfix
Use SendNotifyMessage instead of SendMessage for environment update notifications, since the former is supposedly non-blocking unlike the latter.
Diffstat (limited to '')
-rw-r--r--src/Environment.hs17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/Environment.hs b/src/Environment.hs
index eef1948..9582009 100644
--- a/src/Environment.hs
+++ b/src/Environment.hs
@@ -22,8 +22,9 @@ import Data.List.Split (splitOn)
import Data.Maybe (fromJust, isJust)
import System.IO.Error (catchIOError, isDoesNotExistError)
-import qualified Graphics.Win32.Window as WinAPI
-import qualified System.Win32.Types as WinAPI
+import qualified Graphics.Win32.GDI.Types as WinAPI
+import qualified Graphics.Win32.Message as WinAPI
+import qualified System.Win32.Types as WinAPI
import qualified Registry
import qualified Utils (promptToContinue)
@@ -52,18 +53,20 @@ openRegistryKey env = Registry.openSubKey (openRootKey env) (subKeyPath env)
registryKeyPath :: RegistryLocation -> Registry.KeyPath
registryKeyPath env = Registry.keyPathJoin [Registry.rootKeyPath $ rootKey env, subKeyPath env]
+foreign import ccall "SendNotifyMessageW"
+ c_SendNotifyMessage :: WinAPI.HWND -> WinAPI.WindowMessage -> WinAPI.WPARAM -> WinAPI.LPARAM -> IO WinAPI.LRESULT
+
notifyEnvUpdate :: IO ()
notifyEnvUpdate =
WinAPI.withTString "Environment" $ \lparamPtr -> do
let wparam = 0
let lparam = fromIntegral $ WinAPI.castPtrToUINTPtr lparamPtr
- _ <- WinAPI.sendMessage allWindows messageCode wparam lparam
+ _ <- c_SendNotifyMessage allWindows messageCode wparam lparam
return ()
where
- wM_SETTINGCHANGE = 0x1A
- messageCode = wM_SETTINGCHANGE
-
- allWindows = WinAPI.castUINTPtrToPtr 0xffff
+ messageCode = WinAPI.wM_WININICHANGE
+ hWND_BROADCAST = WinAPI.castUINTPtrToPtr 0xffff
+ allWindows = hWND_BROADCAST
query :: RegistryLocation -> Registry.ValueName -> IO (Maybe Registry.ValueData)
query env name = do