Solved

Calling External DLLs

Posted on 2002-07-03
7
337 Views
Last Modified: 2010-05-18
how to call an external DLL file from php and send its arguments ??
0
Comment
Question by:selim007
  • 3
  • 2
  • 2
7 Comments
 
LVL 40

Accepted Solution

by:
Richard Quadling earned 200 total points
ID: 7126919
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 ...

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

Maybe.

Never tried it.
0
 
LVL 5

Expert Comment

by:Hamlet081299
ID: 7128717
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.
0
 
LVL 2

Author Comment

by:selim007
ID: 7129417
i tried creating a DLL with Visual C++ using the win32 dynamic link library but it's not working with php
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7129423
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.
0
 
LVL 2

Author Comment

by:selim007
ID: 7129441
any ideas on how to compile a dll in order to make it suitable for PHP ?
0
 
LVL 5

Expert Comment

by:Hamlet081299
ID: 7129693
There's a whole section in the manual on writing PHP extensions.  
http://www.php.net/manual/en/phpdevel.php

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.
0
 
LVL 40

Expert Comment

by:Richard Quadling
ID: 7129731
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.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question