Calling External DLLs

how to call an external DLL file from php and send its arguments ??
Who is Participating?
Richard QuadlingConnect With a Mentor Senior Software DeveloperCommented:
You can add PHP extensions using the dl() command. But these create new PHP functions.

I do not know if this will allow you to add any DLL.

You would need to know the actual function name and parameters.

Say you have a function fred in a dll called FRED.DLL

int fred(Int_param,String_param);

You may be able to ...

$result = fred(1,"This is cool.");


Never tried it.
I tried some experiments with PHP and DLL's a while back and had lots of problems.

If you have the tools (eg. Delphi etc), you might want to wrap the DLL in a COM object, which will be much easier to use with PHP.
selim007Author Commented:
i tried creating a DLL with Visual C++ using the win32 dynamic link library but it's not working with php
Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Richard QuadlingSenior Software DeveloperCommented:
Don't PHP extenstions have to be written a certain way as PHP has to know how to deal with the actual extension?

I don't think you can add an ordinary dll (say comctl32.dll). They have to be PHP Extension DLLs.
selim007Author Commented:
any ideas on how to compile a dll in order to make it suitable for PHP ?
There's a whole section in the manual on writing PHP extensions.

I even managed to write an extension in Delphi, which involved a lot of header translations, etc, so C++ should be easy in comparison.

Depending on your purpose though you may well find that COM is a much better solution.

I have a number of COM objects that work nicely under PHP, and the great thing is that I can also use them with other languages, so the same objects are used both within PHP sources and from Delphi apps.
Richard QuadlingSenior Software DeveloperCommented:
I couldn't find a Delphi conversion of the Zend headers.

I would have thought that Project JEDI would have one but I couldn't find it.
All Courses

From novice to tech pro — start learning today.