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
what is the user login name?
Moderator: General Moderators
- pelegk2
- Forum Regular
- Posts: 633
- Joined: Thu Nov 27, 2003 5:02 am
- Location: Israel - the best place to live in after heaven
- Contact:
i have found this code :
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";
?>what can i do?
thanks
peleg