Copyright | (c) Alastair Reid 1997-2003 |
---|---|
License | BSD-style (see the file libraries/base/LICENSE) |
Maintainer | Esa Ilari Vuokko <ei@vuokko.info> |
Stability | provisional |
Portability | portable |
Safe Haskell | Trustworthy |
Language | Haskell2010 |
A collection of FFI declarations for interfacing with Win32.
Synopsis
- try :: String -> (LPTSTR -> UINT -> IO UINT) -> UINT -> IO WindowsString
- failWith :: String -> ErrCode -> IO a
- failIf :: (a -> Bool) -> String -> IO a -> IO a
- failIf_ :: (a -> Bool) -> String -> IO a -> IO ()
- failIfNull :: String -> IO (Ptr a) -> IO (Ptr a)
- failIfZero :: (Eq a, Num a) => String -> IO a -> IO a
- failIfFalse_ :: String -> IO Bool -> IO ()
- failUnlessSuccess :: String -> IO ErrCode -> IO ()
- failUnlessSuccessOr :: ErrCode -> String -> IO ErrCode -> IO Bool
- withFilePath :: WindowsPath -> (LPTSTR -> IO a) -> IO a
- newTString :: WindowsString -> IO LPCTSTR
- withTString :: WindowsString -> (LPTSTR -> IO a) -> IO a
- peekTString :: LPCTSTR -> IO WindowsString
- errorWin :: String -> IO a
- peekTStringLen :: (LPCTSTR, Int) -> IO WindowsString
- withTStringLen :: WindowsString -> ((LPTSTR, Int) -> IO a) -> IO a
- failIfNeg :: (Num a, Ord a) => String -> IO a -> IO a
- useAsCWStringSafe :: WindowsPath -> (CWString -> IO a) -> IO a
- c_wcslen :: CWString -> IO SIZE_T
- nullPtr :: Ptr a
- type LPTSTR = Ptr TCHAR
- type DDWORD = Word64
- type UCHAR = CUChar
- type WORD = Word16
- type LPCWSTR = LPWSTR
- type LPCSTR = LPSTR
- type LPSTR = Ptr CChar
- type LPDWORD = Ptr DWORD
- type LPVOID = Ptr ()
- type LPCTSTR = LPTSTR
- type LPWSTR = Ptr CWchar
- type HANDLE = Ptr ()
- type ErrCode = DWORD
- type ULONG = Word32
- type UINT = Word32
- type DWORD = Word32
- type BYTE = Word8
- type LPBOOL = Ptr BOOL
- type BOOL = Bool
- getLastError :: IO ErrCode
- c_maperrno_func :: ErrCode -> IO Errno
- nullHANDLE :: HANDLE
- iNVALID_HANDLE_VALUE :: HANDLE
- getErrorMessage :: DWORD -> IO LPWSTR
- ddwordToDwords :: DDWORD -> (DWORD, DWORD)
- dwordsToDdword :: (DWORD, DWORD) -> DDWORD
- setLastError :: ErrCode -> IO ()
- maybePtr :: Maybe (Ptr a) -> Ptr a
- ptrToMaybe :: Ptr a -> Maybe (Ptr a)
- type SHORT = Int16
- type INT = Int32
- type ATOM = WORD
- numToMaybe :: (Eq a, Num a) => a -> Maybe a
- type Addr = Ptr ()
- type LONG = Int32
- type LRESULT = LONG_PTR
- type WPARAM = UINT_PTR
- type HINSTANCE = Ptr ()
- type LONG_PTR = CIntPtr
- type LPARAM = LONG_PTR
- maybeNum :: Num a => Maybe a -> a
- castUINTPtrToPtr :: UINT_PTR -> Ptr a
- type LCID = DWORD
- type LANGID = WORD
- type SortID = WORD
- type SubLANGID = WORD
- type PrimaryLANGID = WORD
- mAKELCID :: LANGID -> SortID -> LCID
- lANGIDFROMLCID :: LCID -> LANGID
- sORTIDFROMLCID :: LCID -> SortID
- mAKELANGID :: PrimaryLANGID -> SubLANGID -> LANGID
- pRIMARYLANGID :: LANGID -> PrimaryLANGID
- sUBLANGID :: LANGID -> SubLANGID
- type ULONG_PTR = CUIntPtr
- type SIZE_T = ULONG_PTR
- type HKEY = ForeignHANDLE
- type PKEY = HANDLE
- type LPBYTE = Ptr BYTE
- newForeignHANDLE :: HANDLE -> IO ForeignHANDLE
- type TCHAR = CWchar
- type HMODULE = Ptr ()
- type LPCTSTR_ = LPCTSTR
- type LARGE_INTEGER = Int64
- eRROR_INSUFFICIENT_BUFFER :: ErrCode
- type DWORD32 = Word32
- type DWORD64 = Word64
- type DWORD_PTR = ULONG_PTR
- type USHORT = Word16
- type FLOAT = Float
- type INT32 = Int32
- type INT64 = Int64
- type LONG32 = Int32
- type LONG64 = Int64
- type UINT32 = Word32
- type UINT64 = Word64
- type ULONG32 = Word32
- type ULONG64 = Word64
- type INT_PTR = Ptr CInt
- type UINT_PTR = Word
- type HALF_PTR = Ptr INT32
- type MbString = Maybe String
- type MbINT = Maybe INT
- type MbATOM = Maybe ATOM
- type HRESULT = LONG
- type PUCHAR = Ptr UCHAR
- type MbLPVOID = Maybe LPVOID
- type MbLPCSTR = Maybe LPCSTR
- type MbLPCTSTR = Maybe LPCTSTR
- type ForeignHANDLE = ForeignPtr ()
- deleteObjectFinaliser :: FunPtr (Ptr a -> IO ())
- handleToWord :: HANDLE -> UINT_PTR
- castPtrToUINTPtr :: Ptr s -> UINT_PTR
- type MbHANDLE = Maybe HANDLE
- nullHINSTANCE :: HINSTANCE
- type MbHINSTANCE = Maybe HINSTANCE
- type MbHMODULE = Maybe HMODULE
- nullFinalHANDLE :: ForeignPtr a
- iNVALID_SET_FILE_POINTER :: DWORD
- _open_osfhandle :: CIntPtr -> CInt -> IO CInt
- hANDLEToHandle :: HANDLE -> IO Handle
- internal_lockFile :: CUIntPtr -> Word64 -> Word64 -> CInt -> IO CInt
- internal_getUniqueFileInfo :: HANDLE -> Ptr Word64 -> Ptr Word64 -> IO ()
- c_get_osfhandle :: CInt -> IO HANDLE
- withHandleToHANDLE :: Handle -> (HANDLE -> IO a) -> IO a
- withHandleToHANDLEPosix :: Handle -> (HANDLE -> IO a) -> IO a
- withHandleToHANDLENative :: Handle -> (HANDLE -> IO a) -> IO a
- withStablePtr :: a -> (StablePtr a -> IO b) -> IO b
- eRROR_MOD_NOT_FOUND :: ErrCode
- eRROR_PROC_NOT_FOUND :: ErrCode
- localFree :: Ptr a -> IO (Ptr a)
- lOWORD :: DWORD -> WORD
- hIWORD :: DWORD -> WORD
Documentation
withFilePath :: WindowsPath -> (LPTSTR -> IO a) -> IO a Source #
newTString :: WindowsString -> IO LPCTSTR Source #
withTString :: WindowsString -> (LPTSTR -> IO a) -> IO a Source #
peekTString :: LPCTSTR -> IO WindowsString Source #
peekTStringLen :: (LPCTSTR, Int) -> IO WindowsString Source #
withTStringLen :: WindowsString -> ((LPTSTR, Int) -> IO a) -> IO a Source #
useAsCWStringSafe :: WindowsPath -> (CWString -> IO a) -> IO a Source #
Wrapper around useAsCString
, checking the encoded FilePath
for internal NUL codepoints as these are
disallowed in Windows filepaths. See https://gitlab.haskell.org/ghc/ghc/-/issues/13660
getLastError :: IO ErrCode Source #
nullHANDLE :: HANDLE Source #
setLastError :: ErrCode -> IO () Source #
castUINTPtrToPtr :: UINT_PTR -> Ptr a Source #
type PrimaryLANGID = WORD Source #
lANGIDFROMLCID :: LCID -> LANGID Source #
sORTIDFROMLCID :: LCID -> SortID Source #
mAKELANGID :: PrimaryLANGID -> SubLANGID -> LANGID Source #
pRIMARYLANGID :: LANGID -> PrimaryLANGID Source #
type HKEY = ForeignHANDLE Source #
newForeignHANDLE :: HANDLE -> IO ForeignHANDLE Source #
type LARGE_INTEGER = Int64 Source #
type ForeignHANDLE = ForeignPtr () Source #
handleToWord :: HANDLE -> UINT_PTR Source #
castPtrToUINTPtr :: Ptr s -> UINT_PTR Source #
type MbHINSTANCE = Maybe HINSTANCE Source #
nullFinalHANDLE :: ForeignPtr a Source #
hANDLEToHandle :: HANDLE -> IO Handle Source #
Create a Haskell Handle
from a Windows HANDLE
.
Beware that this function allocates a new file descriptor. A consequence of
this is that calling hANDLEToHandle
on the standard Windows handles will
not give you stdin
, stdout
, or stderr
. For example, if you
run this code:
import Graphics.Win32.Misc
stdoutHANDLE <- getStdHandle sTD_OUTPUT_HANDLE
stdout2 <- hANDLEToHandle
stdoutHANDLE
Then although you can use stdout2
to write to standard output, it is not
the case that
.stdout
== stdout2
internal_getUniqueFileInfo :: HANDLE -> Ptr Word64 -> Ptr Word64 -> IO () Source #
Returns -1 on error. Otherwise writes two values representing the file into the given ptrs.