Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 24th, 2003, 09:59 PM
Registered User
 
Join Date: Jun 2003
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.
 
Old June 30th, 2003, 07:18 AM
Friend of Wrox
 
Join Date: Jun 2003
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
 
Old June 30th, 2003, 09:35 AM
Authorized User
 
Join Date: Jun 2003
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.
 
Old July 1st, 2003, 05:18 AM
Registered User
 
Join Date: Jul 2003
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();
 
Old July 2nd, 2003, 12:11 PM
Registered User
 
Join Date: Jun 2003
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.
 
Old March 15th, 2004, 07:52 AM
Registered User
 
Join Date: Mar 2004
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

 
Old March 15th, 2004, 11:24 AM
Friend of Wrox
 
Join Date: Jun 2003
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.
 
Old March 16th, 2004, 12:50 PM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
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.
 
Old December 16th, 2005, 07:49 PM
Friend of Wrox
 
Join Date: Jul 2004
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.





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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.