hi, i saw some examples on how to use COM objects by PHP 4. but they are all about Excel, Word, ADODB etc.
if i have a library named "mylibrary.dll", how do you make php know the existence of the libray, and how do you know what functions this library provide you, and how do you load the library in the php program?
it dies when i tried to run this program.
<?php
// create an object instance
$mylibrary = new COM("C:\lib\MyLibrary.dll") or die("MyLibrary could not be started");
$mylibrary = null;
?>
1. I have built a DLL to calculate something. Is there any way to run this DLL under PHP ?
If this is a simple DLL there is no way yet to run it from PHP. If the DLL contains a COM server you may be able to access it if it implements the IDispatch interface.
what does the above faq mean? i can't use MyLibrary.dll? how do you know if this particular dll implement the IDispatch interface?
php & com
Moderator: General Moderators
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
A correctly installed COM server will be registered with the system. Calling CoCreateInstance() with the proper GUID will load the DLL and initialize the COM parts associated.
If your dll doesn't implement the COM system components, use win32api
If your dll doesn't implement the COM system components, use win32api
-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
the MyLibrary.dll is working well with the C#.NET interoperability.
i have done the followin:
1) used regsvr32 on MyLibrary.dll
2) found out the dll has 3 class, named ClassA, ClassB, ClassC (from the visual studio.net 2003 object browser)
3) changed the php.ini file to the following:
[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
4) restart aparche
5) make a little php program.
<?php
$myobj = new COM("MyLibrary.ClassA") or die("dead here");
$myobj = null;
?>
it still dies, what's going on?
(minor question: do i need to load all the classes from that dll?)
thankx a lot.
i have done the followin:
1) used regsvr32 on MyLibrary.dll
2) found out the dll has 3 class, named ClassA, ClassB, ClassC (from the visual studio.net 2003 object browser)
3) changed the php.ini file to the following:
[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
4) restart aparche
5) make a little php program.
<?php
$myobj = new COM("MyLibrary.ClassA") or die("dead here");
$myobj = null;
?>
it still dies, what's going on?
(minor question: do i need to load all the classes from that dll?)
thankx a lot.
-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
-
alanchinese
- Forum Newbie
- Posts: 11
- Joined: Fri Jun 11, 2004 4:53 pm
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
whatever interfaces are exposed, you'll have to use QueryInterface() on the IUnknown's you receive..