Page 1 of 1

PHP, COM, Apache, Windows 2000 Professional

Posted: Mon Aug 25, 2003 10:13 pm
by psmshankar
hi,
using VB, i developed a COMTest.dll that contains a class by name "clsTest". I put this dll in to my server running win 2000 professional, apache 1.3, php 4.3.1
I registered that the dll using "regsvr32". Fine.
I want to use this dll in my php program. so tested it with

Code: Select all

<?php
$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");?>


when i run this, a small pop-up window comes up with following error:
php.exe has generated errors..........

etc..
by saying, the page also sows error
The server encountered an internal error or misconfiguration and was unable to complete your request


All the normal php programs are working fine...only when i use COM its showing problem...i think it could not able to instantiate??
the COM settings in my php.ini file is
[com]
; path to a file containing GUIDs, IIDs or filenames of files with TypeLibs
;com.typelib_file =
; allow Distributed-COM calls
com.allow_dcom = true
; autoregister constants of a components typlib on com_load()
com.autoregister_typelib = true
; register constants casesensitive
com.autoregister_casesensitive = false
; show warnings on duplicate constat registrations
com.autoregister_verbose = true
to check whether my registered dll is working fine, i used the same dll in visual basic program in the server itself and it worked fine..
do i need to set anything... i am using win2k professional...
please help me out... :(

Posted: Mon Aug 25, 2003 11:05 pm
by volka
what does COMTest.clsTest expose?

Posted: Mon Aug 25, 2003 11:09 pm
by psmshankar
in that COMTest.cls, i am trying to find whether a device is attached or not.. i am using Nokia Card Phone for my application..
using Nokia SDK, i compiled the dll in VB. That class uses the SDk and chk whether the device is connected or not..
just to start with..

Posted: Mon Aug 25, 2003 11:18 pm
by volka
naaa, that's not what I meant ;)
It was more about methods, constants, enumerations.
Any complex parameter, either [in]/[out,retval]?
Instantiating the object is enough to crash the system?

Where does

Code: Select all

<?php
function doTest()
{
	echo 'new com'; flush();
	$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");
	echo 'unset object'; flush();
	unset($objTest);
	echo 'leave function'; flush();
}

echo 'call function'; flush();
doTest();
echo 'end script'; flush();
?>
crash - if?

Posted: Mon Aug 25, 2003 11:32 pm
by psmshankar
Contains following properties
1.DeviceStatus
2.ErrorNumber
3.ErrorDesc

and the following function:
1.CheckDeviceStatus

Code: Select all

<?php
$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");

$objTest->CheckDeviceStatus();
$DevStatus = $objTest->DeviceStatus;
if($DevStatus==0)
{
echo "The Nokia Card Phone has been removed.<br>";
echo "Cannot continue operation.";
}
unset($objTest);
?>

Posted: Mon Aug 25, 2003 11:58 pm
by psmshankar
CheckDeviceStatus is the function within which the VB code check the status of the device. and a value will get stored in the DeviceStatus property ..

i need to call the function and then only i can get the value in that "DeviceStatus" member variable of the dll

Posted: Tue Aug 26, 2003 12:02 am
by volka
ok, first let's stick to the current problem.
At which point does it crash?

Posted: Tue Aug 26, 2003 1:10 am
by psmshankar
when i run the above php code, it says php exe error...

Posted: Tue Aug 26, 2003 1:30 am
by volka
which doesn't tell you much about where it does crash.
Might be useful to learn more about the exact location the script crashes ;)

Code: Select all

<?php
function dotest()
{
	echo 'create object'; flush();
	$objTest = new COM("COMTest.clsTest") or die("Unable to instantiate clsTest component");
	echo 'invoke function'; flush();
	$objTest->CheckDeviceStatus();
	echo 'get property'; flush();
	$DevStatus = $objTest->DeviceStatus;
	echo 'type of property', gettype($DevStatus); flush();
	if($DevStatus==0)
	{
		echo "The Nokia Card Phone has been removed.<br>";
		echo "Cannot continue operation.";
	}
	echo 'unset object'; flush();
	unset($objTest);
	echo 'leave function'; flush();
}


echo 'call dotest'; flush();
dotest();
echo 'exit script'; flush();
?>

Posted: Tue Aug 26, 2003 1:44 am
by psmshankar
now i am getting the following..
call dotestcreate objectinvoke functionget propertytype of propertyintegerThe Nokia Card Phone has been removed.
Cannot continue operation.unset objectleave functionexit script
it prints that nokia device is not connected... whereas it is connected and by using the same DLL in visual basic, and with same class and methods it is returning corretly and says that nokia phone is connected...

Posted: Tue Aug 26, 2003 1:49 am
by volka
but it does not crash anymore.
That's progress, isn't it? Image

Posted: Tue Aug 26, 2003 1:56 am
by psmshankar
yeah a good progress, but y suddenly it showed no device???
if there is device then i need to instantiate another class and use the member functions of this class to send SMS...

Posted: Tue Aug 26, 2003 11:00 pm
by psmshankar
still it returns the value 0 for the DevStatus

Code: Select all

<?php
$DevStatus = $objTest->DeviceStatus
?>
meaning that no hardware found...
but i have plugged in the nokia hardware and its working fine.. in VB i get the DevStatus value as 1, which means it found the hardware...

Do i need to do any setting for the COM classes so that the PHP can get correct values... even here i wonder as the PHP successfully able to instantiate the class.. but getting the wrong values from the property...
i really donno...not able to move up...

Posted: Wed Aug 27, 2003 11:04 am
by psmshankar
oh my god... i just copied the server vb program into the application server(running win2k) and started the debugger... i run the php sample file and to the surprise, i get the Devstatus value as 1 in the vb dll(when i step into each statement using F8 key) and php gets the correct value and prints nokia found..

but if i don't run the debugger and just run the php script in the browser it shows DevStatus Value 0 and nokia NOT found...
how come???? 8O :? :x :roll: :cry: