Skip to content

Commit 3c26b9b

Browse files
RyanGlScottMistuke
authored andcommitted
Use HMODULE, not HINSTANCE, in type signatures for loadLibrary{,Ex}
Fixes #211.
1 parent 42fda6a commit 3c26b9b

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

System/Win32/DLL.hsc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,12 @@ getProcAddress hmod procname =
6262
withCAString procname $ \ c_procname ->
6363
failIfNull "GetProcAddress" $ c_GetProcAddress hmod c_procname
6464

65-
loadLibrary :: String -> IO HINSTANCE
65+
loadLibrary :: String -> IO HMODULE
6666
loadLibrary name =
6767
withTString name $ \ c_name ->
6868
failIfNull "LoadLibrary" $ c_LoadLibrary c_name
6969

70-
loadLibraryEx :: String -> HANDLE -> LoadLibraryFlags -> IO HINSTANCE
70+
loadLibraryEx :: String -> HANDLE -> LoadLibraryFlags -> IO HMODULE
7171
loadLibraryEx name h flags =
7272
withTString name $ \ c_name ->
7373
failIfNull "LoadLibraryEx" $ c_LoadLibraryEx c_name h flags

System/Win32/DLL/Internal.hsc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ foreign import WINDOWS_CCONV unsafe "windows.h GetProcAddress"
4141
c_GetProcAddress :: HMODULE -> LPCSTR -> IO Addr
4242

4343
foreign import WINDOWS_CCONV unsafe "windows.h LoadLibraryW"
44-
c_LoadLibrary :: LPCTSTR -> IO HINSTANCE
44+
c_LoadLibrary :: LPCTSTR -> IO HMODULE
4545

4646
type LoadLibraryFlags = DWORD
4747

@@ -51,7 +51,7 @@ type LoadLibraryFlags = DWORD
5151
}
5252

5353
foreign import WINDOWS_CCONV unsafe "windows.h LoadLibraryExW"
54-
c_LoadLibraryEx :: LPCTSTR -> HANDLE -> LoadLibraryFlags -> IO HINSTANCE
54+
c_LoadLibraryEx :: LPCTSTR -> HANDLE -> LoadLibraryFlags -> IO HMODULE
5555

5656
foreign import WINDOWS_CCONV unsafe "windows.h SetDllDirectoryW"
5757
c_SetDllDirectory :: LPTSTR -> IO BOOL

System/Win32/WindowsString/DLL.hsc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,12 @@ getModuleHandle mb_name =
4949
maybeWith withTString mb_name $ \ c_name ->
5050
failIfNull "GetModuleHandle" $ c_GetModuleHandle c_name
5151

52-
loadLibrary :: WindowsString -> IO HINSTANCE
52+
loadLibrary :: WindowsString -> IO HMODULE
5353
loadLibrary name =
5454
withTString name $ \ c_name ->
5555
failIfNull "LoadLibrary" $ c_LoadLibrary c_name
5656

57-
loadLibraryEx :: WindowsString -> HANDLE -> LoadLibraryFlags -> IO HINSTANCE
57+
loadLibraryEx :: WindowsString -> HANDLE -> LoadLibraryFlags -> IO HMODULE
5858
loadLibraryEx name h flags =
5959
withTString name $ \ c_name ->
6060
failIfNull "LoadLibraryEx" $ c_LoadLibraryEx c_name h flags

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,11 @@
33
## 2.13.3.1
44

55
* Add function `createFile_NoRetry` (see #208)
6+
* The type signatures for `loadLibrary` and `loadLibraryEx` now refer to
7+
`HMODULE` instead of `HINSTANCE` for consistency with the official Win32
8+
API documentation. Note that `HMODULE` and `HINSTANCE` are both type synonyms
9+
for the same thing, so this only changes the presentation of these functions'
10+
type signatures, not their behavior.
611

712
## 2.13.3.0 July 2022
813

0 commit comments

Comments
 (0)