StrataFrame Forum

Using VB6 ActiveX exe's from VB.NET

http://forum.strataframe.net/Topic7394.aspx

By Tim Dol - 3/9/2007

I am calling a VB6 ActiveX exe from my VB.NET application. It seems to work okay except I when I exit the program the executable is still running in the workstation processes. 

Here is the code used.

Dim AvRebuild as New RebuildUtility.clsRebuild()

AvRebuild.StartXRebuild(......)

I launch a number of other VB6 exe's using System.Diagnostics.Process, where I can add a handler so I can remove the process in the OnProcessExit event.  Is there something similar for ActiveX exe's?

Thanks

Tim

 

By Trent L. Taylor - 3/9/2007

You can do this several ways...each process that is started has a unique process ID (PID) that you can capture, or if you are only going to have one instance on the machine you can just use the code below and close down all processes of that type.  The below code you would add in the FormClosing event (or something of that nature) in your main MDI window.

Dim loProcess As System.Diagnostics.Process

For Each loProcess IN System.Diagnostics.Process.GetProcessByName("MyProcessName")
    Try
        loProcess.Kill()
    Catch ex As Exception
    End Try
Next

Note: You DO NOT provide the extension of the process name.  Just name prefix.

By Tim Dol - 3/9/2007

Is it possible to trap the process ID based on how I am launching the application or can you only do this using System.Diagonstics.Process?
By Trent L. Taylor - 3/9/2007

Well, I assume that since you are talking to the ActiveX control, the ActiveX control is the one launching the process.  If this is the case, then you are going to have to cycle through the processes.  If you launch a process directly then you have more control over capturing the PID.