Archive for 6月 27th, 2012
-
Hello, Win32 API(Haskell) World!
Posted on 6月 27th, 2012 by cx20
Win32 API(Haskell)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
以下は Haskell による Win32 API の呼出し例である。ソースコード
import Graphics.Win32.GDI.Types import System.Win32.Types messageBox :: HWND -> String -> String -> UINT -> IO UINT messageBox hwnd text caption style = withTString text $ c_text -> withTString caption $ c_caption -> failIfZero "MessageBox" $ c_MessageBox hwnd c_text c_caption style foreign import stdcall unsafe "windows.h MessageBoxW" c_MessageBox :: HWND -> LPCTSTR -> LPCTSTR -> UINT -> IO UINT main = messageBox nullHANDLE "Hello, Win32 API(Haskell) World!" "Hello, World!" 0
コンパイル方法
C:¥> ghc hello.hs
実行結果
--------------------------- Hello, World! --------------------------- Hello, Win32 API(Haskell) World! --------------------------- OK ---------------------------