summaryrefslogtreecommitdiff
path: root/ext/w32api/README
blob: 0e77cfe750a4249f1e890be06dcb5d02ea3ca728 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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>