To use ShellExecute or not?

  • Thread starter Thread starter Terry Olsen
  • Start date Start date
T

Terry Olsen

When starting a process, what is the difference between using
ShellExecute or not using it?

I need to start IE when a link is clicked in my app. I want as little
impact to my app as possible. What is the best method for this?

In my case I have it working in a chat application. I use a RTB so that
the links are detected. I click on the link and IE opens without
problem 99% of the time.

If a link is clicked at the exact moment text is being appended to the
RTB, the app crashes with a threading error.

So I guess I want to start the process and return from the call as fast
as possible to see if I can alleviate the problem.

Thanks for any help.
 
Terry Olsen said:
When starting a process, what is the difference between using
ShellExecute or not using it?

What's the alternative? Not starting anything or using an alternate method
to start the application? I recommend to use
'System.Diagnostics.Process.Start' instead of p/invoke with the
'ShellExecute' function.
I need to start IE when a link is clicked in my app. I want as little
impact to my app as possible. What is the best method for this?

In my case I have it working in a chat application. I use a RTB so that
the links are detected. I click on the link and IE opens without
problem 99% of the time.

If a link is clicked at the exact moment text is being appended to the
RTB, the app crashes with a threading error.

Are you adding the text to the textbox from another thread? Are you sure
you are using 'Control.{Invoke, BeginInvoke, InvokeRequired}' to access the
control from the other thread instead of accessing it directly?
 
Here's the code that I call from the SocketReceiveCallback routine...

Delegate Sub ToChatWindowDelegate(ByVal msg As String)
Dim ChatDelegate As New ToChatWindowDelegate(AddressOf ToChatWindow)
Dim ChatObject(0) As Object
Private Sub ToChatWindow(ByVal msg As String)
If msg = "" Then Exit Sub
If txtChat.InvokeRequired Then
ChatObject(0) = msg
txtChat.Invoke(ChatDelegate, ChatObject)
Else
txtChat.AppendText(msg)
End If
End Sub

Here's the code for the LinkClicked event
Private Sub txtChat_LinkClicked(ByVal sender As Object, ByVal e As
System.Windows.Forms.LinkClickedEventArgs) Handles txtChat.LinkClicked
Dim pi As New ProcessStartInfo(e.LinkText)
Process.Start(pi)
End Sub

What I'm wondering is what is the difference between using
pi.UseShellExecute=True and pi.UseShellExecute=False?

Which is better when all you want is to spawn an IE instance and get back as
quickly as possible?
 

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

Back
Top