|
|
CV. W32api functionsEinf�hrung
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().
Warnung | Diese Erweiterung ist
EXPERIMENTELL. Das Verhalten dieser Erweiterung,
einschlie�lich der Funktionsnamen, und alles Andere was hier dokumentiert
ist, kann sich in zuk�nftigen PHP-Versionen ohne Ank�ndigung �ndern. Seien
Sie gewarnt und verwenden Sie diese Erweiterung auf eigenes Risiko.
|
Anforderungen
This extension will only work on Windows systems.
InstallationF�r diese Funktionen ist keine Installation erforderlich,
diese geh�ren zum Grundbestand von PHP. Laufzeit KonfigurationDiese Erweiterung definiert keine Konfigurationseinstellungen in der php.ini. Resource Typen
This extension defines one resource type, used for user defined types.
The name of this resource is "dynaparm".
Vordefinierte Konstanten
Folgende Konstanten werden von dieser Erweiterung definiert und
stehen nur zur Verf�gung, wenn die Erweiterung entweder statisch
in PHP kompiliert oder dynamisch zur Laufzeit geladen wurde.
Beispiele
This example gets the amount of time the system has been running and
displays it in a message box.
Beispiel 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);
?> |
|
User Contributed Notes W32api functions |
|
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])
|
|
|
| |