Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to launch file properties window from winform?

How to launch file properties window from winform?

Scheduled Pinned Locked Moved C#
questiontutorial
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jim Taylor
    wrote on last edited by
    #1

    How can I launch the file properties window (i.e. the window launched by right clicking in windows explorer -> properties) from a win forms app (I have the filename). Jim -- modified at 7:20 Tuesday 13th December, 2005

    C 1 Reply Last reply
    0
    • J Jim Taylor

      How can I launch the file properties window (i.e. the window launched by right clicking in windows explorer -> properties) from a win forms app (I have the filename). Jim -- modified at 7:20 Tuesday 13th December, 2005

      C Offline
      C Offline
      Curtis Schlak
      wrote on last edited by
      #2

      First, declare the following in your class.

      private const int SEE_MASK_INVOKELIST = 0xC;

      public struct SHELLEXECUTEINFO
      {
      public int cbSize;
      public int fMask;
      public IntPtr hwnd;
      [MarshalAs(UnmanagedType.LPTStr)] public string lpVerb;
      [MarshalAs(UnmanagedType.LPTStr)] public string lpFile;
      [MarshalAs(UnmanagedType.LPTStr)] public string lpParameters;
      [MarshalAs(UnmanagedType.LPTStr)] public string lpDirectory;
      public int nShow;
      public IntPtr hInstApp;
      public IntPtr lpIDList;
      [MarshalAs(UnmanagedType.LPTStr)] public string lpClass;
      public IntPtr hkeyClass;
      public int dwHotKey;
      public IntPtr hIcon;
      public IntPtr hProcess;
      }

      [DllImport( "shell32.dll", CharSet=CharSet.Auto )]
      static extern bool ShellExecuteEx( ref SHELLEXECUTEINFO lpExecInfo );

      Then, in your code, invoke it with the following.

      SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
      info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf( info );
      info.lpVerb = "properties";
      info.lpFile = @"THE\PATH\TO\YOUR\FILE\HERE";
      info.hwnd = Handle;
      info.fMask = SEE_MASK_INVOKELIST;
      ShellExecuteEx( ref info );

      .Now, more importantly, I had no idea how to do this until you asked. Here's how I figured it out.

      1. I Googled for: C# "file properties" dialog. This led me to learn about using ShellExecuteEx.
      2. Go to http://www.pinvoke.net to learn about ShellExecuteEx.
      3. Copied the code from the Web page to my project and BAM! it worked.

      Now, you have an immediate and long-term answer. <smile />

      J 1 Reply Last reply
      0
      • C Curtis Schlak

        First, declare the following in your class.

        private const int SEE_MASK_INVOKELIST = 0xC;

        public struct SHELLEXECUTEINFO
        {
        public int cbSize;
        public int fMask;
        public IntPtr hwnd;
        [MarshalAs(UnmanagedType.LPTStr)] public string lpVerb;
        [MarshalAs(UnmanagedType.LPTStr)] public string lpFile;
        [MarshalAs(UnmanagedType.LPTStr)] public string lpParameters;
        [MarshalAs(UnmanagedType.LPTStr)] public string lpDirectory;
        public int nShow;
        public IntPtr hInstApp;
        public IntPtr lpIDList;
        [MarshalAs(UnmanagedType.LPTStr)] public string lpClass;
        public IntPtr hkeyClass;
        public int dwHotKey;
        public IntPtr hIcon;
        public IntPtr hProcess;
        }

        [DllImport( "shell32.dll", CharSet=CharSet.Auto )]
        static extern bool ShellExecuteEx( ref SHELLEXECUTEINFO lpExecInfo );

        Then, in your code, invoke it with the following.

        SHELLEXECUTEINFO info = new SHELLEXECUTEINFO();
        info.cbSize = System.Runtime.InteropServices.Marshal.SizeOf( info );
        info.lpVerb = "properties";
        info.lpFile = @"THE\PATH\TO\YOUR\FILE\HERE";
        info.hwnd = Handle;
        info.fMask = SEE_MASK_INVOKELIST;
        ShellExecuteEx( ref info );

        .Now, more importantly, I had no idea how to do this until you asked. Here's how I figured it out.

        1. I Googled for: C# "file properties" dialog. This led me to learn about using ShellExecuteEx.
        2. Go to http://www.pinvoke.net to learn about ShellExecuteEx.
        3. Copied the code from the Web page to my project and BAM! it worked.

        Now, you have an immediate and long-term answer. <smile />

        J Offline
        J Offline
        Jim Taylor
        wrote on last edited by
        #3

        Thanks, I did search on Google but not with quite the right phrase it seems. Thats another site for the bookmarks :) Jim

        C 1 Reply Last reply
        0
        • J Jim Taylor

          Thanks, I did search on Google but not with quite the right phrase it seems. Thats another site for the bookmarks :) Jim

          C Offline
          C Offline
          Curtis Schlak
          wrote on last edited by
          #4

          Jim, Glad I could help. I understand the "not with quite the right phrase" deal. I have done some interesting research into Information Retrieval and understand that Google is powerful for pretty simple searches, but not the contextual stuff. I hope that last section didn't sound too pedantic. I don't want to insult your intelligence. Just thought I'd give you an insight into my problem solving steps. "we must lose precision to make significant statements about complex systems." -deKorvin on uncertainty

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups