Click here to Skip to main content
15,748,930 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
A project of mine requires that I call a dll using php via a COM object call:

$obj = new COM("SimplAt1Com.SimpleObj") or die ( "Unable to instantiate the COM!");

This call seems to work ok but the moment I try to call a function from the object using:

$result = $obj->put_Name("A") ;

none of the code after this call gets run.

Can anyone shed some light on what could cause this?

Also if anyone has a or knows of a known good dll that has functions that can be called from php in this manner I would be very interested in it. That way I could at least verify my server is set up correctly for such an operation.

Thanks, ~AJ
Posted

Wrap this in a try..catch block so you can output the message of the exception and get more information on what's going wrong. I think the com object isn't registered on the server but have a look at the exception for more info.

try {
$obj = new COM("SimplAt1Com.SimpleObj") or die ( "Unable to instantiate the COM!");

$result = $obj->put_Name("A") ;

} catch (Exception $e) {
    echo 'Caught exception: ',  $e->getMessage(), "\n";
}


Good luck!
 
Share this answer
 
E,
Thanks for the post.

I tried what you suggested...

I get the error:

Fatal error: Call to undefined method com::put_Name()

Do I have to 'define' method's?

If so, is it done in the dll code or in my php script??

hmmmmmmm....

I think I may have just answered my own question; I looked at the code more closely and the function I tried to call was 1.) in a class and 2.) the function that calls the class is a 'Private Sub'.

I think I read somewhere that they need to be 'Public' functions.

Does this sound right?

~AJ
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900