473,386 Members | 2,078 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

shellexecute in C#

Hi,
Is there a same function in .Net as API shellexecute?

Thanks
Nhan
Nov 16 '05 #1
11 81645
Le, Thanh-Nhan,

Take a look at the Process class in the help. I have posted a sample for
you below.

Hope this helps.
------------------

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.Start();
Nov 16 '05 #2
Thanks

"Brian Brown" <Br********@discussions.microsoft.com> schrieb im Newsbeitrag
news:B9**********************************@microsof t.com...
Le, Thanh-Nhan,

Take a look at the Process class in the help. I have posted a sample for
you below.

Hope this helps.
------------------

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.Start();

Nov 16 '05 #3
Hi,
I have tried with System.Diagnostics.Process, but in my case it doesn't work.

I want to call
ShellExecute(0, "open", "mailto:in**@xxx.com?body=yyy&subject=wwwwww, 0, 0, 5)
to open the standart email program ..., as when we click on the hyperlinks mailto:in**@xxx.com?body=yyy&subject=wwwwww

Thanks
Nhan

"Brian Brown" <Br********@discussions.microsoft.com> schrieb im Newsbeitrag news:B9**********************************@microsof t.com...
Le, Thanh-Nhan,

Take a look at the Process class in the help. I have posted a sample for
you below.

Hope this helps.
------------------

System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo.FileName = "cmd.exe";
p.Start();

Nov 16 '05 #4
Le, Thanh-Nhan wrote:
Hi,
Is there a same function in .Net as API shellexecute?

Thanks
Nhan


Yeah, System.Diagnostics.Process class. You can start a program there.

Laimis
Nov 16 '05 #5
Le, Thanh-Nhan,

You can still use the Process class. Try the sample that I have posted
below (watch for line wrap).

I hope this helps.
--------------------

System.Diagnostics.Process p = new System.Diagnostics.Process();
string myMail =
String.Format("mailto:{0}?subject={1}&body={2}","a n****@email.com", "Subject
Goes Here", "This is the body of the email");
p.StartInfo.FileName = myMail;
p.Start();
Nov 16 '05 #6
Thanks for your help.
I have tried your code, but it doesn't work regrettably.

Nhan

"Brian Brown" <Br********@discussions.microsoft.com> schrieb im Newsbeitrag
news:59**********************************@microsof t.com...
Le, Thanh-Nhan,

You can still use the Process class. Try the sample that I have posted
below (watch for line wrap).

I hope this helps.
--------------------

System.Diagnostics.Process p = new System.Diagnostics.Process();
string myMail =
String.Format("mailto:{0}?subject={1}&body={2}","a n****@email.com", "Subject Goes Here", "This is the body of the email");
p.StartInfo.FileName = myMail;
p.Start();

Nov 16 '05 #7
but I want to call a standard email programm on the system of users
computer. I don't know which program will be.
In VB 6 I use
sEmail = "mailto:in**@xxx.com?body=yyy&subject=wwwwww"
call ShellExecute(0, "open", sEmail, 0, 0, 5)

ShellExecute will start email program (as Outlook) and open a window for the
email the given informs.

Thanks
Nhan

"laimis" <si*****@iit.edu> schrieb im Newsbeitrag
news:uQ**************@TK2MSFTNGP10.phx.gbl...
Le, Thanh-Nhan wrote:
Hi,
Is there a same function in .Net as API shellexecute?

Thanks
Nhan


Yeah, System.Diagnostics.Process class. You can start a program there.

Laimis

Nov 16 '05 #8
The example provided was pretty close. All that you need to do in
addition is to tell the process to use ShellExecute. Let me know if
this still doesn't work for you.

string commandText = "mailto:an****@someemail.com";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = commandText;
proc.StartInfo.UseShellExecute = true;
proc.Start();


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #9
Thanks,
I have tried with UseShellExecute.
It still doesn't work. I think, my email system had a problem, or my .NET is
not installed correctly (???) . When I the code to open a text file, it
works, the file is opened in notepad.

Nhan
"Matt Brooks" <so*****@somewhere.net> schrieb im Newsbeitrag
news:ej**************@TK2MSFTNGP10.phx.gbl...
The example provided was pretty close. All that you need to do in
addition is to tell the process to use ShellExecute. Let me know if
this still doesn't work for you.

string commandText = "mailto:an****@someemail.com";
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.StartInfo.FileName = commandText;
proc.StartInfo.UseShellExecute = true;
proc.Start();


*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 16 '05 #10
You can also call ShellExecute directly through Interop if you wish.

<code>
//ShellExecute declaration
[System.Runtime.InteropServices.DllImport("shell32. dll")]
private static extern long ShellExecute(Int32 hWnd, string lpOperation,
string lpFile, string lpParameters, string lpDirectory, long nShowCmd);
</code>

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #11
This should work:
Process myProcess = new Process();
ProcessStartInfo myProcessStartInfo = new
ProcessStartInfo("rundll32.exe" );
myProcessStartInfo.UseShellExecute = false;
myProcessStartInfo.Arguments= "url.dll ,FileProtocolHandler
mailto:www.microsoft.com";
myProcess.StartInfo = myProcessStartInfo;
myProcess.Start();
myProcess.WaitForExit();
myProcess.Close();

Regards,
Jeff
I want to call
ShellExecute(0, "open", "mailto:in**@xxx.com?body=yyy&subject=wwwwww, 0,
0, 5)
to open the standart email program ...,

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 16 '05 #12

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

Similar topics

0
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
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
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
0
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
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
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
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
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
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.