problem with win32 api

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

problem with win32 api

Post by pelegk2 »

i am using the win32_api to read the user login name
when i use 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) 
&#123; 
die("failed"); 
&#125; 

if (!($time = $api->GetTickCount())) 
&#123; 
die("failed"); 
&#125; 

echo "Username: $name<br>\nSystemtime: $time<br>\n"; 

?>
i get a fata error from the server
why?
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Hi, can you please post the error message?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

i will send u a print screen to your email
User avatar
scorphus
Forum Regular
Posts: 589
Joined: Fri May 09, 2003 11:53 pm
Location: Belo Horizonte, Brazil
Contact:

Post by scorphus »

Got it. I'll post it here to other users:

Image

Is it visible? I have to test it from the WAN, can't test it from my LAN.

Cheers,
Scorphus.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

i ssee hte image i sent u but
still where is the problem?
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

?
Post Reply