rundll32

J

Jeff Louie

Too funny

Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo =
new ProcessStartInfo("rundll32.exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.RedirectStandardOutput = true;
myProcessStartInfo.Arguments= "url.dll ,FileProtocolHandler
www.microsoft.com";
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();

Adapted from C++ at work MSDN March 2005.

Regards,
Jeff
 
J

Jeff Louie

Raji... For a number of reasons you may want to set UseShellExecute to
false. Unfortunately you can only call an exe if UseShellExecute is
false. rundll32 lets you "run" a dll even if UseShellExecute is false.

Reasons to set UseShellExecute to false include:
1) you want to redirect output
2) you want to call the process "http://www.microsoft.com" from a
MTAThreaded application.
3) you want to close "http://www.microsoft.com" after a timeout.

Try this from a [MTAThreaded] application

Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new
ProcessStartInfo("http://www.microsoft.com" );
myProcessStartInfo.UseShellExecute = true;
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();

An exception will be thrown. Change the application to [STAThread] and
it works fine. (Sure you can call the IExplore exe, but I am trying to
demo the problem)

Regards,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top