Archive for 1月 7th, 2013

  1. Hello, Win32 API(Groovy) World!

    Posted on 1月 7th, 2013 by cx20

    Win32 API(Groovy)

    Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
    以下は Groovy にて SWT の非公開 API を使用した Win32 API 呼出しの例となっている。

    ソースコード

    import org.eclipse.swt.internal.win32.OS
    import org.eclipse.swt.internal.win32.TCHAR
     
    class Hello {
        static void main (args) {
            def lpText = new TCHAR(0, "Hello, Win32 API World!", true)
            def lpCaption = new TCHAR(0, "Hello, World", true)
            OS.MessageBox(0, lpText, lpCaption, OS.MB_OK )
        }
    }

    コンパイル&実行方法

    C:¥> groovy -cp org.eclipse.swt.win32.win32.x86_3.6.1.v3655c.jar;. Hello.groovy

    実行結果

    ---------------------------
    Hello, World!
    ---------------------------
    Hello, Win32 API World!
    ---------------------------
    OK   
    ---------------------------