PDA

Click to See Complete Forum and Search --> : PHP call Dll Function?


lmf
Dec 21st, 2008, 02:55 AM
Is there a way to use PHP and call dll function?

here is function for C:


const char *CreateCodeWithString(int level, const char *name, const char *templ, unsigned long HFF, unsigned short other1, unsigned short other2, unsigned short other3, unsigned short othe4, unsigned short otherinfo5, const char *wordstring);


DLL: Code.DLL

That function will return a String and that string is what i want to know
Thankx Much if anyone can make me a example.

Sakesaru
Dec 24th, 2008, 11:41 AM
Keep in mind this will only work if the target platform runs a windows OS.

http://nz2.php.net/manual/en/function.system.php


You could potentially do this if you made a binary .exe file to take input, do the fuddling around with the DLL that you'd like, then return the data to the console (the command line). Run it all from PHP and get whatever the app spat out into the console with that.

That should do it.

penagate
Dec 25th, 2008, 10:33 PM
On Windows:
http://au2.php.net/manual/en/ref.w32api.php

On other platforms, you'll need to make a binary as described above and call it with 'system' or 'exec'. This is because the PHP interpreter does not do binary linking when it executes a script.

(Contrary to the advice given, the second method will work on non-Windows platforms.)

If you find yourself doing this often, you might want to investigate creating an extension instead, so that you can call the functions in a native PHP manner.