How to receive output parameters from dll call

Discussion in 'PHP' started by lalalampje, May 8, 2006.

  1. #1
    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?
     
    lalalampje, May 8, 2006 IP
  2. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    TwistMyArm, May 8, 2006 IP
  3. lalalampje

    lalalampje Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Thanks for your reply,
    The dll is generated by CA's cool/advantage/allfusion:plex
    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.
     
    lalalampje, May 9, 2006 IP
  4. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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.
     
    TwistMyArm, May 9, 2006 IP
  5. lalalampje

    lalalampje Peon

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    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?
     
    lalalampje, May 9, 2006 IP
  6. TwistMyArm

    TwistMyArm Peon

    Messages:
    931
    Likes Received:
    44
    Best Answers:
    0
    Trophy Points:
    0
    #6
    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!).
     
    TwistMyArm, May 9, 2006 IP