Re: ActiveX.exe question

From: Schmidt (sss_at_online.de)
Date: 05/22/04


Date: Sat, 22 May 2004 21:39:11 +0200


"MikeD" <nobody@nowhere.edu> schrieb im Newsbeitrag
news:eMYpYA5PEHA.3524@TK2MSFTNGP09.phx.gbl...

> > > 1. Do I have to create Setup for my ActiveX.exe or
> > > it will be enough just to put it on the user workstation?

> > No.

> How is that question answered with a "no"?

Sorry, meant no Setup needed, it will be enough to copy the AX.Exe into the
App.Path, if (like the OP has written) the Base-Setup is already done.

> > > 2.Do I have to use some registration for this component on the
> > > user machine?

> > Yes. You can simply shell your AX-Exe, if CreateObject(...) doesn't
> > work, but you need an account, that has the appropriate Registry-Rights.

> No major complaints about that answer...other than I personally would want
> it registered BEFORE calling CreateObject.

Dim MyAXExeObj as MyAXExeClass

Set MyAXExeObj = CreateObject("MyAXExe.MyAXExeClass")
If MyAXExeObj Is Nothing then 'normally passed only one time
    ShellAndWait App.Path & "\MyAXExe.Exe"
    Set MyAXExeObj = CreateObject("MyAXExe.MyAXExeClass")
    If MyAXExeObj Is Nothing then 'normally not the case
        MsgBox "Useraccount with no Registry-Rights"
        'do something appropriate
    End If
End If

> > > 3. If yes for the previous answer then In case I make some
> > > changes in component without changing its interface
> > > (bynary compatibility) do I have to take any actions except
> > > replacing ActiveX.exe on the user machine?
> > No.

> Not so. As I stated in my reply to Vlad, it's possible to add new
> properties and methods without breaking binary compatibility,

He writes: "without changing its interface" - that means to me - no new
properties or methods (just changes behind the interface), ergo no break in
BinaryCompatibility; so the AXExe can be replaced without problems.

> but these additions to
> the public interface still need registered in order to use them.
> If you don't re-register, you can't use them. At least that's my
> understanding. I don't think any ActiveX component "dynamically"
> re-registers. If I'm wrong, somebody please correct me (and back it up).

You are wrong - re-registering is not needed, you can always create the
base-instance of a class, if the BinComp is not broken (rest is done by
simple interface-casting - if the new functionality matches to the
interface-defs [and IIDs] sitting in the caller, all will be fine).
You can test this yourself very fast (2 minutes), if you have 2 Machines
(connected over LAN).
1. Open an AXExe-Project (Projectname AXExe, Classname CTest) on your
DevelopPC
2. Put the following into CTest:
    Public Sub DoSomething()
        MsgBox "DoSomething"
    End Sub
3. Compile AXExe.exe against a Share on the TestPC
    (AXExe is auto-registered after Compile on the DevelopPC)
4. Open a Standard-Exe-Project on your DevelopPC and name it AXTest
5. Set a reference to AXExe inside AXTest
6. Put the following into Form1:
    Private Sub Form_Load()
    Dim AXExeObj As CTest
        Set AXExeObj = CreateObject("AXExe.CTest")
        AXExeObj.DoSomething
    End Sub
7. Compile AXTest.exe against the Share on the TestPC
8. Register AXExe.exe by Doubleclick on the TestPC
9. Start AXTest.exe on the TestPC

Now it's going to be interesting (simple interface-enhancement)
10. Save the Standard-Exe-Project AXTest and close it.
11. Put the following into CTest inside the AXExe-Project
      Public Sub DoSomething()
          MsgBox "DoSomething"
      End Sub
      Public Sub NewSub()
          MsgBox "NewSub"
      End Sub
12. Set the AXExe-Project to BinComp and compile.
13. Open AXTest (Standard-Exe-Project) again.
14. Put the following into Form1:
      Private Sub Form_Load()
      Dim AXExeObj As CTest
          Set AXExeObj = CreateObject("AXExe.CTest")
          AXExeObj.DoSomething
          AXExeObj.NewSub
      End Sub
15. Compile AXTest.exe
16. Start AXTest.exe on the TestPC without reregistering AXExe.exe
      (--> NewSub will work)

Altough this way (10 to 16) is not recommended for class-enhancements.
It's better done by additional interfaces:
17. Save the Standard-Exe-Project AXTest and close it.
18. Put the following into a new class inside the AXExe-Project
      (name it INew and set it to "Public Not Createable")
        Public Sub NewInterfaceSub()
        End Sub
19. Put the following into CTest inside the AXExe-Project
      Implements INew
      Public Sub DoSomething()
          MsgBox "DoSomething"
      End Sub
      Public Sub NewSub()
          MsgBox "NewSub"
      End Sub
      Private Sub INew_NewInterfaceSub()
          MsgBox "NewInterfaceSub"
      End Sub
20. The AXExe is already BinComp, so compile the project.
21. Open AXTest (Standard-Exe-Project) again.
22. Put the following into Form1:
      Private Sub Form_Load()
      Dim AXExeObj As CTest, AXExeNew As INew
          Set AXExeObj = CreateObject("AXExe.CTest")
          AXExeObj.DoSomething
          AXExeObj.NewSub
          Set AXExeNew = AXExeObj
          AXExeNew.NewInterfaceSub
      End Sub
23. Compile AXTest.exe
24. Start AXTest.exe on the TestPC without reregistering AXExe.exe
      (--> NewSub and NewInterfaceSub will work)

Olaf



Relevant Pages

  • Re: creaping coupling......
    ... but it is a more strict contract than required. ... "I am capable of implementing things via interface XYZ i.e. ... consider specifically that we compile, deploy and then we delete a method to ... IWriteable pipe = new Pipe; ...
    (comp.object)
  • Re: RAD vs. performance
    ... thus they fulfull the number interface and can be used interchangeably. ... I'm not about to ditch statically typed languages ... Because you need whole-program optimisation for a start. ... The benefits of static typing come at compile time. ...
    (comp.lang.misc)
  • Re: Is Direct3D a rip-off of OpenGL?
    ... People who think that a method change in a NEW INTERFACE in DirectX really ... Moving to use a NEW INTERFACE, ... > ago simply isn't going to compile with the latest SDK, ...
    (comp.graphics.api.opengl)
  • Re: Duplicate definition on Interface declaration
    ... Interface class. ... Init() method perhaps? ... There are no conditional compile arguments named "Init". ... definition error when I try to display some forms and/or controls in the IDE ...
    (microsoft.public.vb.general.discussion)
  • Re: Abstract Data Types - Separating Interface from Implementation
    ... >>You seem to be confusing implementation code and client code. ... I don't define any of the functions yet, I just declare them and compile ... Each such file defines an *interface*. ...
    (comp.lang.cpp)