SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    brisbane
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem using COM components. (total newbie)

    Hi everyone,

    I have just started learning PHP. I have installed Apache server 2.0.52 and installed PHP 5 and configured that basics int httpd.conf for PHP to work on the Apache server.

    I am having a problems using the COM components.

    I can created the components and send basic commands to them and it all works.

    But.. I need to catch the events that are fired from the components.

    com_event_sink seems to be the only way to do this in PHP.

    When I use the example code listed below I get the following errors.

    Apache.exe-Apllication Error The instruction at "0x7blabla" referenced memory at "0x00040015". The memory could not be "read".

    code listing from php.net

    HTML Code:
    <?php
    class IEEventSinker {
      var $terminated = false;
    
      function ProgressChange($progress, $progressmax) {
       echo "Download progress: $progress / $progressmax\n";
      }
    
      function DocumentComplete(&$dom, $url) {
       echo "Document $url complete\n";
      }
    
      function OnQuit() {
       echo "Quit!\n";
       $this->terminated = true;
      }
    }
    $ie = new COM("InternetExplorer.Application");
    // note that you don't need the & for PHP 5!
    $sink =& new IEEventSinker();
    com_event_sink($ie, $sink, "DWebBrowserEvents2");
    $ie->Visible = true;
    $ie->Navigate("http://www.php.net");
    while(!$sink->terminated) {
      com_message_pump(4000);
    }
    $ie = null;
    ?>
    I have managed to isolate the problem to the fact that if a component fires an event that contains an [out] variable. This is when I get the error.

    I created a basic component in C++ that fires events with no [out] parameters and i can catch them in my php event sink class. As soon as I add an [out] variable to the event.

    bamb...

    Apache.exe-Apllication Error The instruction at "0x7blabla" referenced memory at "0x00040015". The memory could not be "read".

    I'm not sure whether this is a PHP problem or an Apache configuration problem.

    Can anyone else get the above com_event_sink example to work?

    Do you have to configure Apache in some way to get the com_event_sink functiont to work with events that contain variables? (other forum i suppose)

    Thanks for any help.

    Jai

    P.S Is there another way that I can test if its the actual PHP code or the server?

  2. #2
    SitePoint Addict launchcode's Avatar
    Join Date
    Dec 2004
    Location
    Bristol, UK
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The code you have there (taken from the PHP manual) is not compatible with PHP 5 and is causing what appears to be some kind of overflow error within Apache. I tested it with Apache 1.3.31 (Win32 naturally) and on PHP 5.0.3 the IE window appears and then ultimately the script pumps too much data and Apache errors as you described. Under PHP 4.3.10 it worked without error and closing down the IE window printed out the download progress information. The way the object handling has changed from 4 to 5 is almost certainly responsible for this behaviour.

    Cheers,

    Rich
    Richard Davey

    Launchcode
    PHP Security Guide. Think your scripts are secure? Think again.

  3. #3
    SitePoint Member
    Join Date
    Jan 2005
    Location
    brisbane
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thanks Rich

    hi Rich,

    thanks a lot for tyring that out for me.
    i have been working on this for a couple of days now without success.
    i will definately try again with the configuration you had it working with.

    thanks again,

    Jai

  4. #4
    SitePoint Member
    Join Date
    Jan 2005
    Location
    brisbane
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    No Luck :(

    I uninstalled PHP5 and Apache 2.052.

    Then installed Apache 1.3.31 + PHP 4.3.10.

    Setup Apache to use PHP as module using the "Installing as an Apache module" directions on php.net manual.

    With crossed fingers, tested the sample com_event_sink sample above but unfortunaltly have the same access violation. aaahhhhh!

    Thought maybe it has something to do with using the php module.

    So I,..

    Configured apache to use the PHP CGI binary following the instruction from php.net manual "Installing as a CGI binary"

    ran the same php page..... and.... this time instead of getting a

    Apache.exe-Apllication Error The instruction at "0x7blabla" referenced memory at "0x00040015". The memory could not be "read".

    I now get PHP.exe-Apllication Error The instruction at "0x7blabla" referenced memory at "0x0000000". The memory could not be "read".

    grrrrrrrrrrrrr aaaarrrrrrrrrrrg.

    Is this somthing to do with windows security do you think??

    Or maybe I'm missing out on some configuration thing?

    Thanks again.

    Jai

  5. #5
    SitePoint Addict launchcode's Avatar
    Join Date
    Dec 2004
    Location
    Bristol, UK
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry I don't know enough about it to offer any further suggestions - I would recommend you post your message to the php-general mailing list.

    Cheers,

    Rich
    Richard Davey

    Launchcode
    PHP Security Guide. Think your scripts are secure? Think again.

  6. #6
    SitePoint Member
    Join Date
    Jan 2005
    Location
    brisbane
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks anyway Rich.

    Jai


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •