aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/Registry.hs
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-07-13 03:28:51 +0300
commit54db9a94963826141c79ffe30df0453f85a117c8 (patch)
tree22190418728ed381c1c0c45c2d58c5acfda06423 /src/Registry.hs
parentreorder imports (diff)
downloadwindows-env-54db9a94963826141c79ffe30df0453f85a117c8.tar.gz
windows-env-54db9a94963826141c79ffe30df0453f85a117c8.zip
bugfix + refactoring
Diffstat (limited to '')
-rw-r--r--src/Registry.hs11
1 files changed, 3 insertions, 8 deletions
diff --git a/src/Registry.hs b/src/Registry.hs
index 4aac81d..4a7c593 100644
--- a/src/Registry.hs
+++ b/src/Registry.hs
@@ -83,9 +83,6 @@ exitCodeSuccess = 0
exitCodeFileNotFound :: WinAPI.ErrCode
exitCodeFileNotFound = 0x2
-exitCodeMoreData :: WinAPI.ErrCode
-exitCodeMoreData = 0xea
-
raiseError :: String -> WinAPI.ErrCode -> IO a
raiseError functionName ret
| ret == exitCodeFileNotFound = raiseDoesNotExistError functionName
@@ -121,11 +118,9 @@ getString keyHandle valueName =
alloca $ \dataSizePtr -> do
poke dataSizePtr 0
ret <- WinAPI.c_RegQueryValueEx keyPtr valueNamePtr WinAPI.nullPtr WinAPI.nullPtr WinAPI.nullPtr dataSizePtr
- if ret == exitCodeSuccess
- then return ""
- else if ret /= exitCodeMoreData
- then raiseError "RegQueryValueEx" ret
- else getStringTerminated keyPtr valueNamePtr dataSizePtr
+ if ret /= exitCodeSuccess
+ then raiseError "RegQueryValueEx" ret
+ else getStringTerminated keyPtr valueNamePtr dataSizePtr
where
getStringTerminated keyPtr valueNamePtr dataSizePtr = do
dataSize <- peek dataSizePtr