PHP  
downloads | documentation | faq | getting help | mailing lists | | php.net sites | links | my php.net 
search for in the  
<vpopmail_set_user_quotaw32api_deftype>
view the version of this page
Last updated: Tue, 22 Apr 2003

CV. W32api functions

Introductie

This extension is a generic extension API to DLLs. This was originally written to allow access to the Win32 API from PHP, although you can also access other functions exported via other DLLs.

Currently supported types are generic PHP types (strings, booleans, floats, integers and nulls) and types you define with w32api_deftype().

Waarschuwing

Deze module is EXPERIMENTEEL. Dat betekent, dat het gedrag van deze functies, deze functienamen, in concreto ALLES dat hier gedocumenteerd is in een toekomstige uitgave van PHP ZONDER WAARSCHUWING kan veranderen. Wees gewaarschuwd, en gebruik deze module op eigen risico.

Afhankelijkheden

This extension will only work on Windows systems.

Installatie

Er zijn geen handelingen nodig m.b.t. tot installatie voor deze functies, deze maken deel uit van de kern van PHP.

Configuratie tijdens scriptuitvoer

Deze extensie gebruikt geen configuratie regels.

Resource types

This extension defines one resource type, used for user defined types. The name of this resource is "dynaparm".

Voorgedefineerde constanten

Deze constanten worden gedefineerd door deze extensie, en zullen alleen beschikbaar zijn als de extensie met PHP is meegecompileerd, of als deze dynamisch is geladen vanuit een script.

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)

Voorbeelden

This example gets the amount of time the system has been running and displays it in a message box.

Voorbeeld 1. Get the uptime and display it in a message box

<?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);
?>
Inhoudsopgave
w32api_deftype -- Defines a type for use with other w32api_functions
w32api_init_dtype --  Creates an instance of the data type typename and fills it with the values passed
w32api_invoke_function -- Invokes function funcname with the arguments passed after the function name
w32api_register_function -- Registers function function_name from library with PHP
w32api_set_call_method -- Sets the calling method used


User Contributed Notes
W32api functions
add a note add a note
aidy at gringod dot net
30-Apr-2002 03:40

It should be noted that these functions are definately experimental.

I have got w32api_register_function() to work when using PHP4.2.0 RC4 from command line, but I have been unable to get them to work with Apache1.3.24 (WinNT4), and they seem to cause Apache 2.0.35 (WinNT4) to crash when they are used.

arunasphp at anm dot org
06-Aug-2002 08: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.

noodles at NOSPAMarion-online dot com
13-Sep-2002 06:22

The win32 api with PHP will output useless errors frequently but will still work.

Use @w32api_register_function to suppress the useless errors.

php at frenck dot nl
14-Dec-2002 08:36

"The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP."

The whole API written here isn't working anymore as of version 4.3.0RC1. The W32API Extension is completely rewritten.

If you want to use this extension, than realize that in the new PHP releases your script might not work anymore.???

wobble at gmx dot de
31-Mar-2003 09:09

I played a bit around with the W32API. Here is some code that actually works with the current release of W32API.
The interface changed completely, so all documentation about this extension is out-dated. While the old release
just implemented "plain" functions, the current version offers a class to handle all the API-related operations.
Additionally, functions are now registered using a SQL-like language with a single string.

<?php

$api = new win32;

/*
    BOOL GetUserName(
       LPTSTR lpBuffer, // address of name buffer
       LPDWORD nSize   // address of size of name buffer
    );
   Returns the current thread's username
  "&" passes argument as "refrence" not as "copy"
*/
$api->registerfunction("long GetUserName (string &a, int &b) From advapi32.dll");

/*
  DWORD GetTickCount(VOID)
   Returns the ms the OS is running
*/
$api->registerfunction("long GetTickCount () From Kernel32.dll");

$len = 255;                   // set the length your variable should have
$name = str_repeat("\0", $len); // prepare an empty string
if ($api->GetUserName($name, $len) == 0)
{
   die("failed");
}

if (!($time = $api->GetTickCount()))
{
  die("failed");
}

echo "Username: $name
\nSystemtime: $time
\n";

?>

GOOD LUCK !!

Jan Kleinsorge

wobble at gmx dot de
01-Apr-2003 06:58

I spend the last evening writing a more or less complete documentation of what I figured out from the extensions source-code. Here we go:



Jan Kleinsorge
([email protected])

15-May-2003 07:08
This function/class WILL NOT work with APACHE2 on Win32.
It craches if requested by apache.

if it will be executed with the command line
eg. "php.exe myscript.php" works ;)

add a note add a note

<vpopmail_set_user_quotaw32api_deftype>
 Last updated: Tue, 22 Apr 2003
show source | credits | mirror sites 
Copyright © 2001-2003 The PHP Group
All rights reserved.
This mirror generously provided by: /
Last updated: Mon May 26 17:09:40 2003 CEST