Solved

Calling External DLLs

Posted on 2002-07-03
7
334 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:
RQuadling 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 40

Expert Comment

by:RQuadling
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:RQuadling
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

896 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now