dll execution using PHP, w32api problem
Posted: Thu Sep 25, 2003 8:21 am
Hello everybody!
I have a dll and need to execute it using php.
1. I use PHP version 4.3.0 , Apache 2.0.45
2. I've put the dll into C:\WINNT\system32
3. In php.ini extension=php_w32api.dll is without semi-colons
4. In php.ini enable_dl=On
I've carefully read everything from:
http://gr.php.net/manual/en/ref.w32api.php
and I've used the code below:
<?php
$dbpart ="0";
$session_id="KKKddKKK";
$patient_code = "00000";
$api = new win32;
$ret1=$api->registerfunction(" long Decode_Passwd(string &a, string &b, string &c) From blabla.dll ");
print $ret1; //here gives me 1 ...that means it works fine , indeed this function is registered
$ret=$api->Decode_Passwd( &$session_id, &$dbpart, &$patient_code );
print $ret; //---here returns 0 ....something is wrong. The value of the final variable is not correct
print $session_id; //---it gives me a result like : session_id="0KddKKK";
print $patient_code; //--it gives me : $patient_code = '00000'
print $dbpart; //--it gives me : $dbpart ='0';
?>
The function should return $patient_code='00020' for example.
Everything works fine under command line window (cmd, in windows 2000).
From this link: http://gr.php.net/manual/en/ref.w32api.php
I've successfully used the code below:
<?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
\nSystemtime: $time
\n";
?>
It works fine without any problem .
This dll also works when using Perl.
I cannot understand what am I doing wrong?
I cannot find any diferrent source to take information from.
What should I do?
Any answers appreciated.
Thanks in andvance.
Olga.
I have a dll and need to execute it using php.
1. I use PHP version 4.3.0 , Apache 2.0.45
2. I've put the dll into C:\WINNT\system32
3. In php.ini extension=php_w32api.dll is without semi-colons
4. In php.ini enable_dl=On
I've carefully read everything from:
http://gr.php.net/manual/en/ref.w32api.php
and I've used the code below:
<?php
$dbpart ="0";
$session_id="KKKddKKK";
$patient_code = "00000";
$api = new win32;
$ret1=$api->registerfunction(" long Decode_Passwd(string &a, string &b, string &c) From blabla.dll ");
print $ret1; //here gives me 1 ...that means it works fine , indeed this function is registered
$ret=$api->Decode_Passwd( &$session_id, &$dbpart, &$patient_code );
print $ret; //---here returns 0 ....something is wrong. The value of the final variable is not correct
print $session_id; //---it gives me a result like : session_id="0KddKKK";
print $patient_code; //--it gives me : $patient_code = '00000'
print $dbpart; //--it gives me : $dbpart ='0';
?>
The function should return $patient_code='00020' for example.
Everything works fine under command line window (cmd, in windows 2000).
From this link: http://gr.php.net/manual/en/ref.w32api.php
I've successfully used the code below:
<?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
\nSystemtime: $time
\n";
?>
It works fine without any problem .
This dll also works when using Perl.
I cannot understand what am I doing wrong?
I cannot find any diferrent source to take information from.
What should I do?
Any answers appreciated.
Thanks in andvance.
Olga.