Login to TechLifeForum X
Board Index Go to Reboot.Pro
  • Account Login
  • Register
TechLifeForum
  • Home
  • Members
  • Awards
  • Rules
  • Help
  • Donate
  • Live IRC
TechLifeForum / Programming and Development / .Net Framework Programming v
« Previous 1 ... 19 20 21 22 23 ... 46 Next »
/  Show Shell Properties Dialog With Input File[Advanced Search]
Reply to thread
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5

[C#] Show Shell Properties Dialog With Input File

05-27-2012, 07:42 PM (This post was last modified: 05-27-2012 07:44 PM by AceInfinity.)
Post: #1
AceInfinity Offline
∞ IҊϜIɴITϵ ☭
*****
Microsoft MVP
Posts: 8,697
Joined: Jun 2011
Reputation: 61
Show Shell Properties Dialog With Input File
Demo/Preview:


Here's my code:
Code: (SELECT ALL CODE)
private unsafe void button1_Click(object sender, EventArgs e)
{
    Console.WriteLine(ShowFileProperties(textBox1.Text));
}

[DllImport("SHELL32.DLL", EntryPoint = "ShellExecuteEx", SetLastError = true)]
private static extern int ShellExecute(ref ShellExInfo shell_ex);

private struct ShellExInfo
{
    public int cbSize;
    public int fMask;
    public IntPtr hwnd;
    public string lpVerb;
    public string lpFile;
    public string lpParameters;
    public string lpDirectory;
    public int nShow;
    public IntPtr hInstApp;
    public IntPtr lpIDList;
    public string lpClass;
    public IntPtr hkeyClass;
    public int dwHotKey;
    public IntPtr hIcon;
    public IntPtr hProcess;
}

private int ShowFileProperties(string filename)
{
    const int SEE_MASK_INVOKEIDLIST = 12; const int SW_SHOW = 5;

    ShellExInfo shell_ex = new ShellExInfo()
    {
        cbSize = Marshal.SizeOf(new ShellExInfo()),
        lpFile = filename,
        nShow = SW_SHOW,
        fMask = SEE_MASK_INVOKEIDLIST,
        lpVerb = "Properties"
    };

    return ShellExecute(ref shell_ex);        
}

Return values for ShellExecute:
http://msdn.microsoft.com/en-us/library/...s.85).aspx

ShellExecuteInfo struct:
http://msdn.microsoft.com/en-us/library/...s.85).aspx



Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


Development Site: aceinfinity.net
WWW Find
Reply
05-27-2012, 08:20 PM
Post: #2
blackriderws Offline
Junior Member
**
Posts: 24
Joined: May 2012
Reputation: 2
RE: Show Shell Properties Dialog With Input File
Great Job, looks very interesting. Thanks
Find
Reply
05-27-2012, 09:33 PM (This post was last modified: 05-27-2012 09:43 PM by AceInfinity.)
Post: #3
AceInfinity Offline
∞ IҊϜIɴITϵ ☭
*****
Microsoft MVP
Posts: 8,697
Joined: Jun 2011
Reputation: 61
RE: Show Shell Properties Dialog With Input File
Some other verbs to use for the lpVerb parameter:
Code: (SELECT ALL CODE)
"open"        - see MSDN
"openas"    - Opens dialog when no program is associated to the extension
"opennew"    - see MSDN
"edit"        - see MSDN    
"explore"    - see MSDN
"properties"    - see MSDN
"copy"        - see MSDN
"cut"        - see MSDN
"paste"    - see MSDN
"pastelink"    - pastes a shortcut
"delete"    - see MSDN
"print"    - see MSDN
"printto"    - see MSDN
"find"        - see MSDN

And "runas" which runs the program with admin privilleges.

Note: This could also be done with the Process methods from the System.Diagnostics namespace if anybody knows :)

Code: (SELECT ALL CODE)
ProcessStartInfo ProcInfo = new ProcessStartInfo() {
    FileName = "cmd.exe",
    Arguments = string.Empty,
    CreateNoWindow = true,
    Verb = "runas"
};
Process.Start(ProcInfo);



Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer


Development Site: aceinfinity.net
WWW Find
Reply
Reply to thread


Possibly Related Threads...

Thread: Author Replies: Views: Last Post
   How do you display the file name and path in Me.Text ? william7 13 441 05-10-2013 11:15 PM
Last Post: AceInfinity
   PNG Bomber - File byte size optimization (Created by Ace) AceInfinity 9 749 05-10-2013 03:18 PM
Last Post: AceInfinity
  File writer cedonni 4 195 03-25-2013 04:42 PM
Last Post: cedonni
   Save / Load Config File simx 8 316 02-09-2013 10:16 PM
Last Post: AceInfinity
  Set Control Propeties & Invalidate Control - No Verboose Manual Properties ByteBlast 1 138 01-26-2013 12:25 AM
Last Post: AceInfinity

  • View a Printable Version
  • Send this Thread to a Friend
  • Subscribe to this thread
Forum Jump:


Users browsing this thread
1 Guest(s)
Youtube Facebook Twitter Digg
Return to Top
All content © copyright TechLifeForum
Powered By MyBB, © 2002-2013 MyBB Group
Designed by ThemeFreak
Mobile Version