Contents |
int wb_get_function_address (string fname [, int idlib])
Returns the address of a library function.
The function prepends and appends some special characters to the function name until it finds the function name, then it returns the function address or NULL if the function was not found. These special characters are the most common ones encountered in various types of libraries. For example, if fname is set to "MyFunction", wb_get_function_address() looks for the following function names, in order:
The last two expansion options include a '@' character followed by the number of parameters times 4, which is a standard way to store function names inside DLLs. The loop starts from zero ("@0") and ends when it reaches 20 parameters ("@80").
NOTE: Function names, including the expansion characters, are limited to 255 characters.
The mini-program below shows how to call a Windows function in a single PHP line.
<?
// Shows the current ANSI code-page identifier for the operating system.
include "../include/winbinder.php";
wb_message_box(0, "ANSI code-page identifier: " . wb_call_function(wb_get_function_address("GetACP", wb_load_library("KERNEL"))));
?>
The function get_ticks() returns the number of seconds elapsed since the computer started.
function get_ticks()
{
static $KERNEL = null;
static $GetTickCount = null;
if($KERNEL === null)
$KERNEL = wb_load_library("KERNEL");
if($GetTickCount === null)
$GetTickCount = wb_get_function_address("GetTickCount", $KERNEL);
return (int)(wb_call_function($GetTickCount) / 1000);
}