Help save net neutrality! Learn more.

OLE interface using GetObject

  • Paul Higgins

    Paul Higgins - 2006-08-11

    I am trying to use the OLE interface provided by an application. I can use their interface using VBScript like this:

    Dim MyObject
    Set MyObject = GetObject(,"ShipPlotter.Document")
    Wscript.Echo MyObject.GetshipCount()

    This works fine but if I issue a similiar statements using REXX:

    MyObject = .OLEObject~GetObject(,"Ship.Plotter")

    I get:
    Error 93 running C:\AISTEST\aisolettm.rex line 20: Incorrect call to method
    Error 93.903: Missing argument in method; argument 1 is required

    Checked the OORexx Ref guide and found this:

    This is a class method that allows you to obtain an OLE object through the use of a so-called moniker or
    nickname (a string). A moniker is used to find out which object has to be created or, if it is already
    running, addressed. The moniker itself tells OLE which type of object is required. The optional
    parameter class can be used to specify a subclass of OLEObject, and can be used to obtain an OLE
    object that supports events (the ’WITHEVENTS’ option will be used in this case). This method is similar to
    the Init method where you have to specify a ProgID or CLSID.

    Now what is the moniker for this program? I asked the developers of the application and they didn't know. After more investiagtion on the internet I found the moniker is registered in the IRunningObjectTable. Also, found a program to display all the entries in the irot. When I ran it it found this entry that is only there when the application in question is running:


    So I tried this as the the first parameter in GetObject:

    MyObject = .OLEObject~GetObject("!{EC514892-2203-47DA-B314-A2A6D2B77CF4}")

    but still get MyObject returned as The .Nil Object.

    Does anyone know how to make GetObject to work with a moniker? I am using: Open Object Rexx Interpreter Version3.1.0


    • Paul Higgins

      Paul Higgins - 2006-08-12

      The comma wasn't a mistake but mispelling it was. I actually tried the second parameter the same as in VBS and it returned the error saying the first parameter was required. Also, tried ShipPlotter.Document as the first parameter and it returns the Nil Object as does the moniker with the key. Also tried the moniker as being the path to the exe, with same result.

      • Mark Miesfeld

        Mark Miesfeld - 2006-08-13

        Well, sorry I'm not much help. I don't use the OLE object, so I'm just guessing.

        However, here's a couple of other things to try, maybe they will help.

        The value: "!{EC514892-2203-47DA-B314-A2A6D2B77CF4}" that you used looks like a class ID, but, I don't think it should have the '!' character in front of it.

        The program ID should be a string more like "ShipPlotter.Document".

        The GetObject method does not take a class ID. So, I would try these things.

        1.) Use regedit to search through the registry for: EC514892-2203-47DA-B314-A2A6D2B77CF4 and see if you can match that class ID with a program ID.

        2.) Try to create a new object with that class ID, (where the class ID is a valid parameter,) instead of using GetObject. Something like:

        myObject = .OLEObject~new("{EC514892-2203-47DA-B314-A2A6D2B77CF4}")

        and see if you get back an object.

        3.) Use the program: oleinfo.rex that comes with Open Object REXX, (it is in the samples subdirectory under samples\ole\oleinfo to see if you can locate more information about the ShipPlotter.

    • Paul Higgins

      Paul Higgins - 2006-08-14

      Thanks for helping out Mark. I searched the registry with that hey and found the following 4 entries:

      HKEY_CLASSES_ROOT\CLSID{EC514892-2203-47DA-B314-A2A6D2B77CF4} data = ShipPLDocument
      HKEY_CLASSES_ROOT\ShipPlotter.Document\CLSID data = {EC514892-2203-47DA-B314-A2A6D2B77CF4}
      HKEY_LOCAL_MACHINE\SOFTWARE\Classes\CLSID{EC514892-2203-47DA-B314-A2A6D2B77CF4} data = ShipPlDocument HKEY_LOCAL_MACHINE\SOFTWARE\Classes\ShipPlpotter.Document\CLSID data ={EC514892-2203-47DA-B314-A2A6D2B77CF4} data = ShipPlDocument

      Using either ShipPlotter.Document or the key I can create a new instance of the application:

      my = .OLEObject~New("ShipPlotter.Document")
      my = .OLEObject~New("={EC514892-2203-47DA-B314-A2A6D2B77CF4}")

      If I execute either of those I can see using the task manager that there is another instance of the ShipPlotter.exe process created.

      When I do create an new instance, I can access its methods but I am not accessing the original running program so I don't get back the information I want.

      I think I could use .OLEObject~New to start up the original ShipPlotter.exe program but it requires you to press a button to start its processing. Alternatively it has a command line startup option: "/start" that will cause it to start processing without pressing any button. I wonder if there is a way to create a new instance and pass the /start parameter to the program?

      I tried the oleinfo.rex and it does find the ShipPlotter.Document but says it has no methods or events.

    • Mark Miesfeld

      Mark Miesfeld - 2006-08-12

      Maybe this was just a typo, but if not a typo it is probably the cause of the problem:

      MyObject = .OLEObject~GetObject(,"Ship.Plotter")

      According to the syntax you showed, the "Ship.Plotter" parameter should be the first parameter not the second.

      The comma you have preceding "Ship.Plotter" should not be there.

    • Mark Miesfeld

      Mark Miesfeld - 2006-08-12

      Sorry, I should have looked closer before my last post.

      In addtion to the comma, which shouldn't be there, why do you use: "ShipPlotter.Document" as the parameter in the successful case and then use: "Ship.Plotter"

      If the parameter is "ShipPlotter.Document" then I don't see any reason why "Ship.Plotter" would work.

      The docs say the so-called moniker is a nickname, before trying something like: !{EC514892-2203-47DA-B314-A2A6D2B77CF4} I would try passing in the same 'moniker' that works using VBScript.


Log in to post a comment.