aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/lib/WindowsEnv/Utils.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2017-03-25 05:56:02 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2017-03-25 05:56:02 +0300
commit80f6847645459dfd21e531946e1eeaf2384a2dff (patch)
tree8a93e818fe647974bd724be08092e9475d03425f /lib/WindowsEnv/Utils.hs
parentadd README to the package (diff)
downloadwindows-env-80f6847645459dfd21e531946e1eeaf2384a2dff.tar.gz
windows-env-80f6847645459dfd21e531946e1eeaf2384a2dff.zip
rename directories
Diffstat (limited to 'lib/WindowsEnv/Utils.hs')
-rw-r--r--lib/WindowsEnv/Utils.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/WindowsEnv/Utils.hs b/lib/WindowsEnv/Utils.hs
new file mode 100644
index 0000000..c852229
--- /dev/null
+++ b/lib/WindowsEnv/Utils.hs
@@ -0,0 +1,30 @@
+-- |
+-- Copyright : (c) 2016 Egor Tensin <Egor.Tensin@gmail.com>
+-- License : MIT
+-- Maintainer : Egor.Tensin@gmail.com
+-- Stability : experimental
+-- Portability : Windows-only
+
+module WindowsEnv.Utils
+ ( notifyEnvironmentUpdate
+ ) where
+
+import Foreign.C.Types (CIntPtr(..))
+import qualified Graphics.Win32.GDI.Types as WinAPI
+import qualified Graphics.Win32.Message as WinAPI
+import qualified System.Win32.Types as WinAPI
+
+foreign import ccall "Windows.h SendNotifyMessageW"
+ c_SendNotifyMessage :: WinAPI.HWND -> WinAPI.WindowMessage -> WinAPI.WPARAM -> WinAPI.LPARAM -> IO WinAPI.LRESULT
+
+notifyEnvironmentUpdate :: IO ()
+notifyEnvironmentUpdate =
+ WinAPI.withTString "Environment" $ \lparamPtr -> do
+ let wparam = 0
+ let lparam = fromIntegral $ WinAPI.castPtrToUINTPtr lparamPtr
+ _ <- c_SendNotifyMessage allWindows messageCode wparam lparam
+ return ()
+ where
+ messageCode = WinAPI.wM_WININICHANGE
+ hWND_BROADCAST = WinAPI.castUINTPtrToPtr 0xffff
+ allWindows = hWND_BROADCAST