Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than shell32, prefix the name with the module name and a period.
SHObjectProperties (shell32)
.
Sample Code:
C#
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
public class Program
{
[DllImport("shell32.dll", SetLastError=true)]
static extern bool SHObjectProperties(UInt32 hwnd, UInt32 shopObjectType, [MarshalAs(UnmanagedType.LPWStr)] string pszObjectName, [MarshalAs(UnmanagedType.LPWStr)] string pszPropertyPage);
public static void Main()
{
SHObjectProperties(0,2,"C:\\Windows",null);
Console.ReadKey();
}
}
Declare Function SHObjectProperties Lib "shell32.dll" _
(ByVal hwnd As UInt32, ByVal shopObjectType As UInt32, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszObjectName As String, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszPropertyPage As String) As Boolean
User-Defined Types:
Optional Enum used to set shopObjectType for pszObjectName:
Public Enum GetProperties
SHOP_PRINTERNAME = &H1 '// lpObject points to a printer friendly name
SHOP_FILEPATH = &H2 '// lpObject points to a fully qualified path+file name
SHOP_VOLUMEGUID = &H4 '// lpObject points to a Volume GUID
End Enum
Alternative Managed API:
Do you know one? Please contribute it!
Notes:
Took me forever (okay, less than an hour) to figure out that this function failed with Integers or Longs and it wanted UInt32 for hwnd and shopObjectType.
Tips & Tricks:
Please add some!
Sample Code:
VB
Sub Main()
ShowProp("C:\boot.ini")
'needed to keep the properties window open (window is bound to current application handle)
Console.ReadKey()
End Sub
Public Enum GetProperties
SHOP_PRINTERNAME = &H1 '// lpObject points to a printer friendly name
SHOP_FILEPATH = &H2 '// lpObject points to a fully qualified path+file name
SHOP_VOLUMEGUID = &H4 '// lpObject points to a Volume GUID
End Enum
Private Declare Function SHObjectProperties Lib "shell32.dll" _
(ByVal hwnd As UInt32, ByVal shopObjectType As UInt32, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszObjectName As String, _
<MarshalAs(UnmanagedType.LPWStr)> ByVal pszPropertyPage As String) As Boolean
Public Function ShowProp(ByVal filename As String, Optional ByVal page As String = "") As Boolean
If page = String.Empty Then
page = 0
Else
page = page
End If
ShowProp = SHObjectProperties(0, GetProperties.SHOP_FILEPATH, filename, String.Empty)
End Function
TODO - a short description of this collection of constants
4/6/2012 12:59:20 AM - anonymous
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).