Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 24th, 2003, 09:59 PM
Registered User
 
Join Date: Jun 2003
Location: , , Singapore.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Use of VB.NET's Shell function in C#

Hi,

Does anyone know how I can use the VB.NET's Shell function in C#? I understand that there is an equivalent one in the .NET Framework but just could not find out which one.

Thanks.


Best regards,

Jude.
Reply With Quote
  #2 (permalink)  
Old June 30th, 2003, 07:18 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , .
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

Hi Jude

I did some searching myself and found that it realy is
difficult to find a function that works like VB.Net's Shell.

However being a VC++ guy I know a function a API
called ShellExecute that I have used a lot.
I've used this api in C# as well its pretty simple
here is the declaration code

Code:
        [DllImport("Shell32.dll",CharSet=CharSet.Auto)]
        public static extern IntPtr ShellExecute(
            IntPtr hwnd, 
            string lpVerb,
            string lpFile, 
            string lpParameters, 
            string lpDirectory,
            int nShowCmd );
and this is how you use it
Code:
ShellExecute(this.Handle,"open","notepad","","",3);
I've used 3 as the value for the last perameter.
which maps to SW_SHOWMAXIMIZED;
you can find the values to use for the last
perameter in WINUSER.H located in
whereeveryouhaveintalledit\Microsoft Visual Studio\VC98\Include

The search for the Shell counterpart is still on.

Write back if there is anything else you wanna ask.


Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
Reply With Quote
  #3 (permalink)  
Old June 30th, 2003, 09:35 AM
Authorized User
 
Join Date: Jun 2003
Location: , , .
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Try using System.Diagnostics.Process from framework. It has all the functionality you are looking for.

Paul.
Reply With Quote
  #4 (permalink)  
Old July 1st, 2003, 05:18 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 9
Thanks: 0
Thanked 0 Times in 0 Posts
Default

try this:

using System.Diagnostics ;
...........
...........
Process p = new Process();
p.StartInfo = new ProcessStartInfo("notepad.exe");
p.StartInfo.UseShellExecute = true;
p.Start();
Reply With Quote
  #5 (permalink)  
Old July 2nd, 2003, 12:11 PM
Registered User
 
Join Date: Jun 2003
Location: , , Singapore.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Thanks to Desp and psingh. I also found a good article on it at http://www.csharpfriends.com/Article...?articleID=122


Best regards,

Jude.
Reply With Quote
  #6 (permalink)  
Old March 15th, 2004, 07:52 AM
Registered User
 
Join Date: Mar 2004
Location: Pune, Maharashtra, India.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hello,
  My question is can we execute, internal DOS commands like del,copy,ren etc... using System.Diagnostic ?

 As illustrated in the examples below DOS commands like notepade.exe or ping.exe can be executed or any other exe files.

 How to execute DOS internal command like del and pass the arguments to it ?

TIA
Abhijit

Reply With Quote
  #7 (permalink)  
Old March 15th, 2004, 11:24 AM
Friend of Wrox
Points: 3,558, Level: 25
Points: 3,558, Level: 25 Points: 3,558, Level: 25 Points: 3,558, Level: 25
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: California, USA
Posts: 996
Thanks: 2
Thanked 11 Times in 11 Posts
Send a message via Yahoo to melvik
Default

FIRST I wonder why u wanna use DOS commands while u r using windows programming THEN why not windows. u have FILE Object to work with ur files in ur PC.
HTH.

Always:),
Hovik Melkomian.
Reply With Quote
  #8 (permalink)  
Old March 16th, 2004, 12:50 PM
planoie's Avatar
Friend of Wrox
Points: 16,481, Level: 55
Points: 16,481, Level: 55 Points: 16,481, Level: 55 Points: 16,481, Level: 55
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2003
Location: Clifton Park, New York, USA.
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

Look into the System.IO namespace for functions pertaining to file operations.
Particularly System.IO.File.

Peter
------------------------------------------------------
Work smarter, not harder.
Reply With Quote
  #9 (permalink)  
Old December 16th, 2005, 07:49 PM
Friend of Wrox
 
Join Date: Jul 2004
Location: Tehran, , Iran.
Posts: 623
Thanks: 0
Thanked 1 Time in 1 Post
Default

Quote:
quote:How to execute DOS internal command like del and pass the arguments to it ?
use the static start method of the process class,it accepts two argument which the second one is the arguments..
Code:
            // url's are not considered documents. They can only be opened
            // by passing them as arguments.
            Process.Start("IExplore.exe", "www.northwindtraders.com");
_____________
Mehdi.
software student.
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to put result of shell function into variable method Beginning VB 6 1 April 20th, 2006 11:42 AM
Shell keyword in VB dpkbahuguna Beginning VB 6 4 February 16th, 2006 01:49 AM
Using the Shell Function RAPSR59 Access 1 April 13th, 2005 07:14 AM
shell function problem bml Excel VBA 1 February 12th, 2005 05:42 PM
Shell Function Question SerranoG Access VBA 4 November 12th, 2003 07:57 PM



All times are GMT -4. The time now is 12:42 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.