473,489 Members | 2,492 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

To use ShellExecute or not?

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.

*** Sent via Developersdex http://www.developersdex.com ***
Jan 12 '06 #1
2 2082
"Terry Olsen" <to******@hotmail.com> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 12 '06 #2
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?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
"Terry Olsen" <to******@hotmail.com> schrieb:
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?

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Jan 13 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
2546
by: Marcel Sammut | last post by:
Greetings, I am converting a VB6 application to .net and am having troubles trying to print a document directley to the printer. My VB6 app used the API ShellExecute method to accomplish this,...
3
5449
by: Wiktor Zychla | last post by:
I have a problem I cannot solve. My application hosts IE activex control. I follow the standard procedure: I just aximp shdocvw.dll. Note that this gives you two files: axshdocvw.dll and...
1
2297
by: MCzajk | last post by:
Is there a function similar to ShellExecute, which I can hook to when the program is started using Start Menu icon? MCzajk
11
81659
by: Le, Thanh-Nhan | last post by:
Hi, Is there a same function in .Net as API shellexecute? Thanks Nhan
0
1804
by: the_openFace | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
0
1584
by: the openBack | last post by:
I'm trying to display the shell's property page for various files and I'm using this code: class Win32Shell { // ... other stuff here public static extern Int32 ShellExecute( Int32 hwnd,...
0
1838
by: David | last post by:
We have an mfc application in which we use ShellExecute to launch the browser with an initial web site. {ShellExecute( NULL, "open", "http://www.SomeWebSite.com", NULL, NULL, SW_SHOWNORMAL ) } ...
4
3408
by: fdmaxey | last post by:
I currently start a target executable written in VB.Net from an application that uses a C-script language. I start the target executable using ShellExecute in the C-script. The target runs fine...
1
3071
by: bugs bunny via .NET 247 | last post by:
Does anyone have actually used SetWindowsHookEx() to hook upShellExecute() so as to find what application was started bywindows or which folder is currently browsed by explorer. I knowone thing and...
2
10702
by: John Smith | last post by:
Hi, I have an access database form with an image. I'm trying to create an onclick event on the image so that when a user clicks on the image it opens that file with the default viewer the...
0
7108
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7181
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6847
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7352
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4875
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4565
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1383
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
618
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
272
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.