w32api_deftype> <vpopmail_set_user_quota
Last updated: Mon, 29 Oct 2007

CLXXIII. W32api 函数

简介

本扩展库是用于连接 DLL 的通用扩展 API。它最初是用来允许从 PHP 中访问 Win32 API,不过也可以访问通过其它 DLL 导出的其它函数。

目前支持的有 PHP 的标准类型(string,boolean,float,integer 和 null)以及用 w32api_deftype() 函数所自定义的类型。

注意: 本扩展已被移动到 » PECL 库中且自以下版本起不再被绑定到 PHP 中:5.1.0。

警告

本扩展模块是实验性的。本模块的行为,包括其函数的名称以及其它任何关于此模块的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本扩展模块风险自担。

需求

本扩展只能工作在 Windows 系统中。

安装

本扩展模块作为 PHP 内核的一部分,无需安装即可使用。

运行时配置

本扩展模块在 php.ini 中未定义任何配置选项。

资源类型

本扩展定义了一种资源类型,用于用户自定义类型。此资源名为 "dynaparm"

预定义常量

以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。

DC_MICROSOFT (integer)
DC_BORLAND (integer)
DC_CALL_CDECL (integer)
DC_CALL_STD (integer)
DC_RETVAL_MATH4 (integer)
DC_RETVAL_MATH8 (integer)
DC_CALL_STD_BO (integer)
DC_CALL_STD_MS (integer)
DC_CALL_STD_M8 (integer)
DC_FLAG_ARGPTR (integer)

范例

以下例子演示如何得到系统持续运行的时间,并把它显示在一个消息对话框中。

例2391.得到系统持续运行的时间,并把它显示在消息对话框中

<?php
// 定义所需的常量,来自
// Visual Studio/Tools/Winapi/WIN32API.txt
define("MB_OK", 0);

// 加载此扩展
dl("php_w32api.dll");

// 注册 GetTickCount 函数,来自 kernel32.dll
w32api_register_function("kernel32.dll",
          
"GetTickCount",
          
"long");

// 注册 MessageBoxA 函数,来自 User32.dll
w32api_register_function("User32.dll",
          
"MessageBoxA",
          
"long");

// 取得开机时间信息
$ticks = GetTickCount();

// 转换为易于理解的文本
$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));

// 显示一个消息对话框,只有一个 OK 按钮和上面的开机时间文本
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 设置调用的方法


add a note add a note User Contributed Notes
W32api 函数
There are no user contributed notes for this page.

w32api_deftype> <vpopmail_set_user_quota
Last updated: Mon, 29 Oct 2007