Hello, Win32 API(ClojureCLR) World!

Posted on 6月 21st, 2012 by cx20

Win32 API(ClojureCLR)

Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
ClojureCLR には Win32 API を直接呼び出す機能は実装されていないが、C# を経由することで、Win32 API を呼び出すことが可能となっている。

ソースコード(C#)

using System;
using System.Runtime.InteropServices;
 
namespace Win32Lib
{
    public class Win32
    {
         [DllImport("user32.dll", CharSet=CharSet.Auto)]
         public extern static uint MessageBox(IntPtr hWnd, string lpText, string lpCaption, uint uType);
    }
}

コンパイル方法(C#)

C:¥> csc /target:library Win32Lib.cs

ソースコード(ClojureCLR)

(System.Reflection.Assembly/LoadFrom "Win32Lib.dll")
(Win32Lib.Win32/MessageBox 0  "Hello, Win32 API(ClojureCLR) World!" "Hello, World!", 0 )

実行方法

C:¥> Clojure.Main hello.clj

実行結果

---------------------------
Hello, World!
---------------------------
Hello, Win32 API(ClojureCLR) World!
---------------------------
OK   
---------------------------

Tags:

Categories: .NET, ClojureCLR, Win32 API

コメントを残す

メールアドレスが公開されることはありません。 * が付いている欄は必須項目です

WP-SpamFree by Pole Position Marketing