Tech Off Thread

3 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

System.Runtime.InteropServices (pinvoke) in C#

Back to Forum: Tech Off
  • User profile image
    candseeme

    /// <summary>
      /// This function invokes the Properties context menu command on a Shell object.
      /// </summary>
      /// <param name="hwnd">[in] The HWND of the window that will be the parent of the dialog box.</param>
      /// <param name="dwType">enum to what to call</param>
      /// <param name="szObject">[in] A NULL-terminated Unicode string that contains the object name.
      /// The contents of the string are determined by which of
      /// the first three flags are set in dwType.</param>
      /// <param name="szPage">[in] A NULL-terminated Unicode string that contains the name of
      /// the property sheet page to be initially opened.
      /// Set this parameter to NULL to specify the default page.</param>
      /// <returns>Returns TRUE if the Properties command is successfully invoked, or FALSE otherwise.</returns>

      [DllImport("shell32.dll", EntryPoint="SHObjectProperties", CharSet = CharSet.Auto)]
      public static extern bool CallPropDialog
       ( IntPtr hwnd, GetProperties dwType, string szObject, string szPage );


    with this static method you may call the properties dialog of any object in windows
    not just that but you can specify the initial tab
    usually a property dialog contains tabs
    Genrral, Summary, Security ( if in winxp) Version if it is an (.exe, .dll etc.)

    an example of this would be

    CallPropDialog ( this.Handle,
     GetProperties.SHOP_FILEPATH, "c\\windows\\notepad.exe" ,
    null )

    where  GetProperties.SHOP_FILEPATH is an enum

    here it is

    /// <summary>
      /// this enum used on conjuction with getobjectproberties
      /// </summary>
      public enum GetProperties
      {
       SHOP_PRINTERNAME = 0x00000001,  // lpObject points to a printer friendly name
       SHOP_FILEPATH = 0x00000002,  // lpObject points to a fully qualified path+file name
       SHOP_VOLUMEGUID = 0x00000004  // lpObject points to a Volume GUID
      };

  • User profile image
    Sven Groot

    You should check out http://www.pinvoke.net/, it's a fairly good resource with PInvoke signatures and samples.

  • User profile image
    candseeme

    Sven Groot wrote:

    You should check out http://www.pinvoke.net/, it's a fairly good resource with PInvoke signatures and samples.



    thank you sven !
    yes i know but i post that for fun and if anyone wanna see an example of the pinvoke in .Net

    Thanks

    Cool

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.