open browser

  • Thread starter Thread starter Chris
  • Start date Start date
Here's the code I usually use:

[DllImport("coredll.Dll",SetLastError=true)]

private static extern int CreateProcess(string imageName, string cmdLine,
int lpProcessAttributes, int lpThreadAttributes, Int32 boolInheritHandles,
Int32 dwCreationFlags, int lpEnvironment, int lpszCurrentDir, int[] si,
ProcessInfo pi);

static public void LaunchURL(string URL)

{

int[] si = new int[128];

ProcessInfo pi = new ProcessInfo();

CreateProcess(@"\windows\iexplore.exe", URL, 0, 0, 0, 0, 0, 0, si, pi);

}

And then define this class in the same namespace:

class ProcessInfo

{

public IntPtr hProcess;

public IntPtr hThread;

public Int32 ProcessID;

public Int32 ThreadID;

}

It's not pretty, but it gets the job done in throw away apps. You may want
to add in exception handling for the p/invoke call.
 
Back
Top