private PSGetPropertyKeyFromName ( [ pszCanonicalName, PropertyKey &propkey ) : int | ||
pszCanonicalName | [ | |
propkey | PropertyKey | |
return | int |
/// <summary> /// Gets the property description for a given property's canonical name. /// </summary> /// <param name="canonicalName">Canonical name of the property whose description is required.</param> /// <returns>Property Description for a given property key</returns> public static ShellPropertyDescription GetPropertyDescription(string canonicalName) { int result = PropertySystemNativeMethods.PSGetPropertyKeyFromName(canonicalName, out PropertyKey propKey); if (!CoreErrorHelper.Succeeded(result)) { // todo: some localized messages could now apply only for the Shell project (and not for Win32Native), so they should be moved to the Shell project. throw new ArgumentException(LocalizedMessages.ShellInvalidCanonicalName, Marshal.GetExceptionForHR(result)); } return(ShellPropertyDescriptionsCache.Cache.GetPropertyDescription(propKey)); }
/// <summary> /// Writes the specified property given the canonical name and a value. To allow truncation of the given value, set allowTruncatedValue /// to true. /// </summary> /// <param name="canonicalName">The canonical name.</param> /// <param name="value">The property value.</param> /// <param name="allowTruncatedValue">True to allow truncation (default); otherwise False.</param> /// <exception cref="System.ArgumentException">If the given canonical name is not valid.</exception> public void WriteProperty(string canonicalName, object value, bool allowTruncatedValue) { // Get the PropertyKey using the canonicalName passed in int result = PropertySystemNativeMethods.PSGetPropertyKeyFromName(canonicalName, out PropertyKey propKey); if (!CoreErrorHelper.Succeeded(result)) { throw new ArgumentException( LocalizedMessages.ShellInvalidCanonicalName, Marshal.GetExceptionForHR(result)); } WriteProperty(propKey, value, allowTruncatedValue); }
internal IShellProperty CreateTypedProperty(string canonicalName) { // Otherwise, call the native PropertyStore method PropertyKey propKey; int result = PropertySystemNativeMethods.PSGetPropertyKeyFromName(canonicalName, out propKey); if (!CoreErrorHelper.Succeeded(result)) { throw new ArgumentException( LocalizedMessages.ShellInvalidCanonicalName, Marshal.GetExceptionForHR(result)); } return(CreateTypedProperty(propKey)); }