can't get return value from COM in PHP5

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • klingus@gmail.com

    can't get return value from COM in PHP5

    I am running into problems obtaining the return value of a method I
    have in a COM+ DLL.

    I have the following code snippet:

    STDMETHOD(add)( long num1, long num2, long* result);

    STDMETHODIMP CsampleApp::add (long num1, long num2, long *result)
    {
    *result = num1 + num2;

    return S_OK;
    }

    I wrote a PHP script to invoke this method. It can't get the new value
    from this function.

    <?php
    echo "Call Com Object<br>";
    $instance = new COM("sampleApp. SimpleCom");

    $instance ->test(1, 2, $returnValue);
    echo "Return should be: " . $returnValue;

    $instance->release();
    ?>

    I am getting $returnValue = 0 instead of 3.

    I have tried using Variants but that is not going well. I am hoping
    someone may be able to assist me.

    Thank you in advance.
    Kelvin

  • Steve

    #2
    Re: can't get return value from COM in PHP5

    [color=blue]
    > I am running into problems obtaining the return value of a method I
    > have in a COM+ DLL.[/color]
    [color=blue]
    > STDMETHOD(add)( long num1, long num2, long* result);
    >
    > STDMETHODIMP CsampleApp::add (long num1, long num2, long *result)
    > {
    > *result = num1 + num2;
    >
    > return S_OK;
    > }[/color]
    [color=blue]
    > I wrote a PHP script to invoke this method. It can't get the new value
    > from this function.[/color]
    [color=blue]
    > <?php
    > echo "Call Com Object<br>";
    > $instance = new COM("sampleApp. SimpleCom");[/color]
    [color=blue]
    > $instance ->test(1, 2, $returnValue);
    > echo "Return should be: " . $returnValue;[/color]
    [color=blue]
    > $instance->release();
    > ?>[/color]
    [color=blue]
    > I am getting $returnValue = 0 instead of 3.[/color]

    Could it be because... the method name in your COM component is "add"
    but you are calling a method "test" in your PHP instance? Or possibly
    because you need to pass $returnValue by reference (ie &$returnValu e)
    because it's supposed to be a pointer? Or maybe both?

    ---
    Steve

    Comment

    • klingus@gmail.com

      #3
      Re: can't get return value from COM in PHP5

      Hi Steve,

      Thanks for replying. The method name difference is a typo on my part.
      Sorry about that.

      I tried passing $returnValue by reference but the value is still 0
      instead of 3.

      Thanks,
      Kelvin

      Comment

      Working...