Search
Module:
Directory

   Desktop Functions:

   Smart Device Functions:


Show Recent Changes
Subscribe (RSS)
Misc. Pages
Comments
FAQ
Helpful Tools
Playground
Suggested Reading
Website TODO List
Download Visual Studio Add-In

SHRunFileDialog (shell32)
 
.

Opens the typical 'Run' dialog used by the start menu, without explorer.exe.

C# Signature:

[DllImport("shell32.dll", CharSet=CharSet.Auto, EntryPoint="#61", SetLastError=true)]
static extern bool SHRunFileDialog(IntPtr hwndOwner, IntPtr hIcon, string lpszPath, string lpszDialogTitle, string lpszDialogTextBody, RunFileDialogFlags uflags);

User-Defined Types:

    [Flags()]
    public enum RunFileDialogFlags : uint
    {
        /// <summary>
        /// Don't use any of the flags (only works alone)
        /// </summary>
        None = 0x0000,
        /// <summary>
        /// Removes the browse button
        /// </summary>
        NoBrowse = 0x0001,
        /// <summary>
        /// No default item selected
        /// </summary>
        NoDefault = 0x0002,
        /// <summary>
        /// Calculates the working directory from the file name
        /// </summary>
        CalcDirectory = 0x0004,
        CalcDirectory = 0x0003,
        /// <summary>
        /// Removes the edit box label
        /// </summary>
        NoLabel = 0x0008,
        /// <summary>
        /// Removes the seperate memory space checkbox (Windows NT only)
        /// </summary>
        NoSeperateMemory = 0x0020    
    }

Alternative Managed API:

Use the Documented IShellDispatch->Run(), but this can be a pain in C# if you are pressed for time.

Notes:

None.

Tips & Tricks:

You can pass zero or more flags to the function. If the function fails, check your character encoding. It seems that it expects Unicode characters by default.

Sample Code:

        string path;
        string dialogtitle;
        string dialogtext;

        path = "C:\\WiNDOWS";
        dialogtitle = "Start Application";
        dialogtext = "Enter the name of the program file you wish to run.  You may also enter in URLs and items found in your path and applications list.";

        SHRunFileDialog(
        RunFileDlg(
        this.Handle,
        this.Icon.Handle,
        path,
        dialogtitle,
        dialogtext,
        RunFileDialogFlags.CalcDirectory
        );

Submitted by Gabriel Sharp (http://paradisim.net)

Documentation
Undocumented by Microsoft - Thanks to Armen Hakobyan for his article on codeproject

Please edit this page!

Do you have...

  • helpful tips or sample code to share for using this API in managed code?
  • corrections to the existing content?
  • variations of the signature you want to share?
  • additional languages you want to include?

Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).

 
Access PInvoke.net directly from VS:
Terms of Use
Edit This Page
Find References
Show Printable Version
Revisions