Hello, Win32 API(Phalanger) World!
Posted on 6月 22nd, 2012 by cx20
Win32 API(Phalanger)
Win32 API は、Windows の機能にアクセスする為の API(Application Programming Interface)である。
Phalanger には 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);
}
} |
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 |
C:¥> csc /target:library Win32Lib.cs
ソースコード(Phalanger)
<?
use System;
use Win32Lib;
$win32 = new Win32LibWin32();
$win32->MessageBox( new SystemIntPtr(0), "Hello, Win32 API(Phalanger) World!", "Hello, World!", 0);
?> |
<?
use System;
use Win32Lib;
$win32 = new Win32LibWin32();
$win32->MessageBox( new SystemIntPtr(0), "Hello, Win32 API(Phalanger) World!", "Hello, World!", 0);
?>
コンパイル方法(Phalanger)
C:¥> phpc /lang:pure /r:Win32Lib.dll Hello.php |
C:¥> phpc /lang:pure /r:Win32Lib.dll Hello.php
実行結果
---------------------------
Hello, World!
---------------------------
Hello, Win32 API(Phalanger) World!
---------------------------
OK
--------------------------- |
---------------------------
Hello, World!
---------------------------
Hello, Win32 API(Phalanger) World!
---------------------------
OK
---------------------------
Tags: Win32 API
Categories: .NET, Phalanger, Win32 API