note 30826 added to ref.w32api

From: Date: Mon, 31 Mar 2003 19:09:35 +0000
Subject: note 30826 added to ref.w32api
Groups: php.notes 
Request: Send a blank email to php-notes+get-46019@lists.php.net to get a copy of this message
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<br>\nSystemtime: $time<br>\n"; ?> GOOD LUCK !! Jan Kleinsorge -- http://www.php.net/manual/en/ref.w32api.php http://master.php.net/manage/user-notes.php?action=edit+30826 http://master.php.net/manage/user-notes.php?action=delete+30826 http://master.php.net/manage/user-notes.php?action=reject+30826

« previous php.notes (#46019) next »