Groups | Blog | Home
all groups > c# > december 2004 >

c# : shellexecute in C#


Brian Brown
12/31/2004 11:21:02 AM
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";
Le, Thanh-Nhan
12/31/2004 7:56:23 PM
Hi,
Is there a same function in .Net as API shellexecute?

Thanks
Nhan

Le, Thanh-Nhan
12/31/2004 11:40:41 PM
Thanks

"Brian Brown" <BrianBrown@discussions.microsoft.com> schrieb im Newsbeitrag
news:B92E8086-5FBD-42B6-BB2C-7145CCD15702@microsoft.com...
[quoted text, click to view]

Le, Thanh-Nhan
1/1/2005 5:45:42 AM
Hi,
I have tried with System.Diagnostics.Process, but in my case it doesn't =
work.

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

Thanks
Nhan



"Brian Brown" <BrianBrown@discussions.microsoft.com> schrieb im =
Newsbeitrag news:B92E8086-5FBD-42B6-BB2C-7145CCD15702@microsoft.com...
[quoted text, click to view]
Brian Brown
1/1/2005 10:41:03 AM
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}","anyone@email.com", "Subject
Goes Here", "This is the body of the email");
p.StartInfo.FileName = myMail;
laimis
1/1/2005 12:27:37 PM
[quoted text, click to view]

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

Le, Thanh-Nhan
1/3/2005 11:07:52 AM
Thanks for your help.
I have tried your code, but it doesn't work regrettably.

Nhan

"Brian Brown" <BrianBrown@discussions.microsoft.com> schrieb im Newsbeitrag
news:59170F67-9548-450A-B9BE-3438A2CE77CC@microsoft.com...
[quoted text, click to view]

Le, Thanh-Nhan
1/3/2005 11:32:52 AM
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:info@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" <simulai@iit.edu> schrieb im Newsbeitrag
news:uQeNF#C8EHA.1408@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Matt Brooks
1/19/2005 1:09:18 PM
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:anyone@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 ***
Nhan
1/19/2005 10:31:43 PM
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" <someone@somewhere.net> schrieb im Newsbeitrag
news:ejTxksm$EHA.4072@TK2MSFTNGP10.phx.gbl...
[quoted text, click to view]

Lee Tibbett
2/16/2005 12:16:44 PM
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 ***
Jeff Louie
2/16/2005 8:24:20 PM
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:info@xxx.com?body=yyy&subject=wwwwww, 0,
0, 5)
to open the standart email program ...,

*** Sent via Developersdex http://www.developersdex.com ***
AddThis Social Bookmark Button