Hi,
I need start IE in new window without addressbar, status bar but I cannot use kiosk mode (I need defined window size).
I need to know the processID of the IE process also.

I have 2 different codes:

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "C:\Program Files\Internet Explorer\IEXPLORE.EXE";
p.StartInfo.Arguments = "http://google.cz";
p.Start();
int pid = p.Id;

This code starts the new IE window and returns its PID, but it cannot hide address bar, status bar and so on..


The second code:

System.Type oType = System.Type.GetTypeFromProgID("InternetExplorer.Application");
object o = System.Activator.CreateInstance(oType);
o.GetType().InvokeMember("menubar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
o.GetType().InvokeMember("toolbar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
o.GetType().InvokeMember("statusBar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
o.GetType().InvokeMember("addressbar", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { 0 });
o.GetType().InvokeMember("Visible", System.Reflection.BindingFlags.SetProperty, null, o, new object[] { true });

It starts IE window without address bar, status bar.. but I don't know, howto find processID of the IE instance..

Please help..

Regards,
Petr

It hasn't any process created for it!! it attached to your application. but also if you terminate the application it doesn't (fuzzy) read in GetTypeFromProgID documentation

I know this is an ugly bump but I've been trying to figure out this exact scenario with still no resolution. I've shorten up the code based off various google searches with the result as:

Type oType = Type.GetTypeFromProgID("InternetExplorer.Application");
if (oType != null)
{
    SHDocVw.InternetExplorer ie = Activator.CreateInstance(oType) as SHDocVw.InternetExplorer;

    if (ie != null)
    {
        object oEmpty = String.Empty;
        object oURL = "http://www.somewhere.com";
        ie.AddressBar = false;
        ie.MenuBar = false;
        ie.ToolBar = 0;
        ie.Visible = true;
        ie.Navigate2(ref oURL, ref oEmpty, ref oEmpty, ref oEmpty, ref oEmpty);
    }
}

To get the process id, I have found it possible to use:

[System.Runtime.InteropServices.DllImport("user32.dll")]
public static extern uint GetWindowThreadProcessId(IntPtr hwnd, out uint lpdwProcessId);

However, I've found that using the Activator.CreateInstance will not create new processes. For example, let's say you have an IE browser open already (outside this app) with process id 1000. If this code is ran to launch another browser window, there is indeed a new window separate from the already opened window however it has the same process id of 1000. If you were to do a Process.Close() on id 1000, it would close both IE windows. Is there any way to do a CreateInstance having it create a new instance with a new process id?

Thanks,
-Nelis

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.