例子 1. 得到系统持续运行的时间,并把它显示在消息对话框中 <?php // Define constants needed, taken from // Visual Studio/Tools/Winapi/WIN32API.txt define("MB_OK", 0);// Load the extension in dl("php_w32api.dll");// Register the GetTickCount function from kernel32.dll w32api_register_function("kernel32.dll", "GetTickCount", "long");// Register the MessageBoxA function from User32.dll w32api_register_function("User32.dll", "MessageBoxA", "long");// Get uptime information $ticks = GetTickCount();// Convert it to a nicely displayable text $secs = floor($ticks / 1000); $mins = floor($secs / 60); $hours = floor($mins / 60);$str = sprintf("You have been using your computer for:". "\r\n %d Milliseconds, or \r\n %d Seconds". "or \r\n %d mins or\r\n %d hours %d mins.", $ticks, $secs, $mins, $hours, $mins - ($hours*60));// Display a message box with only an OK button and the uptime text MessageBoxA(NULL, $str, "Uptime Information", MB_OK); ?> w32api_deftype -- 为 w32api_functions 函数定一个类型 w32api_init_dtype -- 创建了一个数据类型的实例,并且将函数传入的值填入其中 w32api_invoke_function -- 带有一个参数的执行一个函数,参数传递在函数名的后面 w32api_register_function -- 从函数库中使用 PHP 注册一个函数 function_name w32api_set_call_method -- 设置调用的方法
<?php
// Define constants needed, taken from
// Visual Studio/Tools/Winapi/WIN32API.txt
define("MB_OK", 0);// Load the extension in
dl("php_w32api.dll");// Register the GetTickCount function from kernel32.dll
w32api_register_function("kernel32.dll",
"GetTickCount",
"long");// Register the MessageBoxA function from User32.dll
w32api_register_function("User32.dll",
"MessageBoxA",
"long");// Get uptime information
$ticks = GetTickCount();// Convert it to a nicely displayable text
$secs = floor($ticks / 1000);
$mins = floor($secs / 60);
$hours = floor($mins / 60);$str = sprintf("You have been using your computer for:".
"\r\n %d Milliseconds, or \r\n %d Seconds".
"or \r\n %d mins or\r\n %d hours %d mins.",
$ticks,
$secs,
$mins,
$hours,
$mins - ($hours*60));// Display a message box with only an OK button and the uptime text
MessageBoxA(NULL,
$str,
"Uptime Information",
MB_OK);
?> w32api_deftype -- 为 w32api_functions 函数定一个类型
w32api_init_dtype -- 创建了一个数据类型的实例,并且将函数传入的值填入其中
w32api_invoke_function -- 带有一个参数的执行一个函数,参数传递在函数名的后面
w32api_register_function -- 从函数库中使用 PHP 注册一个函数 function_name
w32api_set_call_method -- 设置调用的方法
2、既然是UNIX,那拿来的dll
用插件读本地数据.
在插件中建立一个 socket 连接并发送数据就可以了.
这个不是PHP问题.