471,330 Members | 1,508 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,330 software developers and data experts.

Accessing a running ActiveX C# Exe from WebBrowser

Hi

I want to start a C# ActiveX Exe with a parameter.
Now, start a WebBrowser. Within Html/javascript I initiate my component
und want to retrieve the parameter from the startet exe.

I have done this in VB6 with new ActiveXObject("name") and all works
correct.

Using C# or Vb.net it works different:

- When the WenBroser calls the Exe, it starts its own process (the 2't
exe is not shown in the Taskmanager, only in ProcessExplorer).

- It return on this problem the empty value

- in the Browser Instance I can use this 2't exe instance (can set and
get new value)

What can I do to get the parameter from the startet exe outside the
browser instance? (the instance with the given paramter)

I have not found how to implement GetObject. this could solve also my
problem.
Sample Javascript code:

var oCorrespondenceControl;
oCorrespondenceControl = new ActiveXObject("AppPort.PortHolder");
oCorrespondenceControl.Display();

Classes of the Project:

Program:
[STAThread]
public static void Main(string[] args)
ActiveXObject.PORT = arg.Trim().Substring(6);
Thread.CurrentThread.SetApartmentState(ApartmentSt ate.STA);
Application.Run();
}
ActiveXObject:

[ProgId("AppPort.PortHolder")]
[ClassInterface(ClassInterfaceType.AutoDual),
ComSourceInterfaces(typeof(ControlEvents))] //Implementing interface
that will be visible from JS
[Guid("121C3E0E-DC6E-45dc-952B-A6617F0FAB42")]
[ComVisible(true)]
public class ActiveXObject : IObjectSafetyImpl

public ActiveXObject()
{
Thread.CurrentThread.SetApartmentState(ApartmentSt ate.STA);
}

[ComVisible(true)]
public void Display()
{
MessageBox.Show(PORT);
}
Thank you
tobias
Jul 28 '08 #1
1 4972
Tobias,

I think that what you want is the static GetActiveObject on the Marshal
class in the System.Runtime.InteropServices namespace.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Tobias Maier" <To**********@web.dewrote in message
news:48**************@web.de...
Hi

I want to start a C# ActiveX Exe with a parameter.
Now, start a WebBrowser. Within Html/javascript I initiate my component
und want to retrieve the parameter from the startet exe.

I have done this in VB6 with new ActiveXObject("name") and all works
correct.

Using C# or Vb.net it works different:

- When the WenBroser calls the Exe, it starts its own process (the 2't exe
is not shown in the Taskmanager, only in ProcessExplorer).

- It return on this problem the empty value

- in the Browser Instance I can use this 2't exe instance (can set and get
new value)

What can I do to get the parameter from the startet exe outside the
browser instance? (the instance with the given paramter)

I have not found how to implement GetObject. this could solve also my
problem.
Sample Javascript code:

var oCorrespondenceControl;
oCorrespondenceControl = new ActiveXObject("AppPort.PortHolder");
oCorrespondenceControl.Display();

Classes of the Project:

Program:
[STAThread]
public static void Main(string[] args)
ActiveXObject.PORT = arg.Trim().Substring(6);
Thread.CurrentThread.SetApartmentState(ApartmentSt ate.STA);
Application.Run();
}
ActiveXObject:

[ProgId("AppPort.PortHolder")]
[ClassInterface(ClassInterfaceType.AutoDual),
ComSourceInterfaces(typeof(ControlEvents))] //Implementing interface that
will be visible from JS
[Guid("121C3E0E-DC6E-45dc-952B-A6617F0FAB42")]
[ComVisible(true)]
public class ActiveXObject : IObjectSafetyImpl

public ActiveXObject()
{
Thread.CurrentThread.SetApartmentState(ApartmentSt ate.STA);
}

[ComVisible(true)]
public void Display()
{
MessageBox.Show(PORT);
}
Thank you
tobias

Jul 29 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

18 posts views Thread by Joe | last post: by
3 posts views Thread by AdamM | last post: by
1 post views Thread by kp | last post: by
10 posts views Thread by Febronio | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.