2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

PHPでWin32APIを呼ぶ(Windows)

Last updated at Posted at 2016-04-05
  • DynamicWrapper をインストールする
  • php.ini で php_com_dotnet.dll を有効化する
  • サンプル・コード
  • 参考

PHP5.6.3で動作確認@2016-04-05

不備があれば教えてください。

DynamicWrapper をインストール

  1. dynawrapNt.zip をダウンロード
  2. 管理者権限でコマンドプロンプトを起動
  3. regsvr32.exe path_to_dynawrapNt\dynwrap.dllでインストール

php.ini で php_com_dotnet.dll を有効化

extension=php_com_dotnet.dll

を追加。

サンプル・コードを実行

# コマンドプロンプトで実行
C:\php php -f sample.php

sample.php


<?php
	$win32 = new COM("DynamicWrapper");

	$win32->Register("user32.dll", "MessageBoxA", "i=hssu", "f=s", "r=l");
	$win32->MessageBoxA(null, "MessageBoxA", "Sample", 3); # MessageBoxを表示

	$win32->Register("KERNEL32.DLL", "GetTickCount", "i=l", "f=s", "r=l");
	echo $win32->GetTickCount(0); # 起動時間を表示
?>

参考

2
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?