I would like to call a dll from PHP which does all kinds of things for me already, such as collecting data from a database. This dll will be called through a shell exe. Untill now I'm able to call the dll and in the dll I receive the input parameters fine. But I don't seem to be able to get the output parameters back from it into PHP. I now use a line like: $execstring="shell.exe Test_DLL.dll Test_DLL $inpar1 $inparr2 $outpar1 $outpar2"; What would be the proper way to receive the output parameters correctly, or is this impossible?
Is this a DLL you have written yourself? Is there any reason you don't use the W32API PHP code? Anyway, assuming you want to go the exec string way, you shoul be able to take your $execstring variable then use it something like: $output = array(); exec( $execstring, $output ); I believe... then your $output variable should have all of the lines of output saved into an array.
Thanks for your reply, The dll is generated by CA's cool/advantage/allfusionlex I guess with your output methode you catch the output to the screen of the dll, instead of the output parameters. My dll however does not output anything to the screen. Therefore the array stays empty.
Oh OK: I see where you're going (I missed that you were passing in the output parameters). I don't know if this is possible if only for the fact that you would need to be passing your output parameters from PHP, to the shell, to the DLL and back again, all by reference. I would hazard a guess and say that you would either have to write your own DLL or EXE wrapper to the library or use the W32API from within PHP.
I tried your other suggestion, but I don't seem to be able to get the php_w32api.dll loaded under PHP 5.1.4. Isn't this a module for older versions only?
According to http://php.net/w32api it's not, but it has been moved in to the PECL at http://pecl.php.net/ . I daresay that site may have more information on installation and use. If worse comes to worst, believe it or not, it's fairly simple to write your own PHP extensions (assuming your C is up to scratch!).