473,406 Members | 2,698 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,406 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 81649
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.