超越PHP PHP动态 | 经典文章 | CLASS | 相关下载 | 常见问题 | FORUM | WIKI | 在线手册
Site search:    
<vpopmail_set_user_quotaw32api_deftype>
Last updated: Fri, 22 Jun 2007

CXXI. W32api 函数库

简介

这是对于 DLL 的通用扩展 API。它最初是用来允许从 PHP 中访问 Win32 API,尽管这样你仍然可以通过它访问其它 DLL。

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

警告

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

需求

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

安装

这些函数作为 PHP 核心的一部分,无需被安装即可使用。

运行时配置

该扩展模块未定义任何设置指令。

资源类型

这个扩展定义了一个资源类型,被用作用户自定义类型。这个类型的名称是 "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)

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

例子 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 -- 设置调用的方法



add a note add a note User Contributed Notes
W32api 函数库
arunasphp at anm dot org
06-Aug-2002 04:32
In order to use most (perhaps all?) of the win32 API while running with a web server you have to give the server service permission to interact with the desktop.  This is especially noticeable with the given example, where the script will try to display message boxes on the server's display.

Keep in mind, however, that you should think hard about the consequences of letting a web server interact with your desktop, especially if you're not the only one using the web server.

<vpopmail_set_user_quotaw32api_deftype>
 Last updated: Fri, 22 Jun 2007
view source | feedback | send page | sitemap | aboutus   
Copyright ® 2002-2003 PHPE.NET. All rights reserved
Last updated:2002-11-22