Page 1 of 1

what is the user login name?

Posted: Wed Jan 07, 2004 1:19 am
by pelegk2
how can i check with what user name the user has logged to hus computer?
its possibe in asp is it possible in php?
thanks in advance
peleg

Posted: Wed Jan 07, 2004 4:38 am
by m3mn0n
Maybe using the win32 API...click to learn more: [php_man]w32api[/php_man]

i have found this code :

Posted: Thu Jan 08, 2004 2:23 am
by pelegk2

Code: Select all

<?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";

?>
but when i run the page i get fatal error messages from the apache!!!!:(
what can i do?
thanks
peleg

Posted: Thu Jan 08, 2004 3:14 am
by Weirdan
You cant use winapi from php compiled as module. It works only in cgi version. Perhaps it's the matter of your problem.

Posted: Thu Jan 08, 2004 5:15 am
by pelegk2
i cant run cgi

Posted: Thu Jan 08, 2004 5:17 am
by Pyrite
He means using the php.exe to parse your php pages instead of the dll.