php-src/ext/w32api
2002-04-16 14:19:09 +00:00
..
examples Maintain headers. 2002-02-28 08:29:35 +00:00
test_dll Maintain headers. 2002-02-28 08:29:35 +00:00
CREDITS Fix CREDIT files, remove email address 2002-03-13 18:45:39 +00:00
EXPERIMENTAL @ - Add generic Win 32 API extension (jmoore) 2001-11-07 14:31:03 +00:00
php_w32api.h Maintain headers. 2002-02-28 08:29:35 +00:00
README @ - Add generic Win 32 API extension (jmoore) 2001-11-07 14:31:03 +00:00
TODO @ - Add generic Win 32 API extension (jmoore) 2001-11-07 14:31:03 +00:00
w32api.c Added missing function to function_entry 2002-04-16 14:19:09 +00:00
w32api.dsp @ - Add generic Win 32 API extension (jmoore) 2001-11-07 14:31:03 +00:00

Win 32 API Extension
====================
/* $Revision$ */

This extension is a generic extension api to dll's. This was originally written to allow access to the Win32 API from PHP. Although you can also access other functions exported via other DLL's.

An example of getting the amount of time the system has been running and displaying it in a message box:

========================== Example.php =====================================
<?php

        dl("php_w32api.dll");
        
        w32api_register_function("kernel32.dll", 
                                 "GetTickCount",
                                 W32_LONG);
                                 
        w32api_register_function("User32.dll",
                                 "MessageBoxA",
                                 W32_LONG);

        $ticks = w32api_invoke_function("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));

        w32api_invoke_function("MessageBoxA", 
                                NULL, 
                                $str, 
                                "Uptime Information", 
                                MB_OK);
?>
============================================================================

Currently supported types are generic PHP types (strings, bools, doubles, longs and null's) others will be added as and when I can figure out the best way of converting between types.

Thanks to Ton Plooy for the base code for the generic calling function.

- James Moore <jmoore@php.net>