private SHCreateItemFromIDList ( |
||
pidl | ||
riid | System.Guid | |
ppv | [ | |
리턴 | int |
public ChangeNotifyLock(Message message) { IntPtr pidl; IntPtr lockId = ShellNativeMethods.SHChangeNotification_Lock( message.WParam, (int)message.LParam, out pidl, out _event); try { Trace.TraceInformation("Message: {0}", (ShellObjectChangeTypes)_event); var notifyStruct = pidl.MarshalAs <ShellNativeMethods.ShellNotifyStruct>(); Guid guid = new Guid(ShellIIDGuid.IShellItem2); if (notifyStruct.item1 != IntPtr.Zero && (((ShellObjectChangeTypes)_event) & ShellObjectChangeTypes.SystemImageUpdate) == ShellObjectChangeTypes.None) { IShellItem2 nativeShellItem; if (CoreErrorHelper.Succeeded(ShellNativeMethods.SHCreateItemFromIDList( notifyStruct.item1, ref guid, out nativeShellItem))) { string name; nativeShellItem.GetDisplayName(ShellNativeMethods.ShellItemDesignNameOptions.FileSystemPath, out name); ItemName = name; Trace.TraceInformation("Item1: {0}", ItemName); } } else { ImageIndex = notifyStruct.item1.ToInt32(); } if (notifyStruct.item2 != IntPtr.Zero) { IShellItem2 nativeShellItem; if (CoreErrorHelper.Succeeded(ShellNativeMethods.SHCreateItemFromIDList( notifyStruct.item2, ref guid, out nativeShellItem))) { string name; nativeShellItem.GetDisplayName(ShellNativeMethods.ShellItemDesignNameOptions.FileSystemPath, out name); ItemName2 = name; Trace.TraceInformation("Item2: {0}", ItemName2); } } } finally { if (lockId != IntPtr.Zero) { ShellNativeMethods.SHChangeNotification_Unlock(lockId); } } }
/// <summary>Constructs a new Shell object from IDList pointer</summary> /// <param name="idListPtr"></param> /// <returns></returns> internal static ShellObject Create(IntPtr idListPtr) { // Throw exception if not running on Win7 or newer. CoreHelpers.ThrowIfNotVista(); var guid = new Guid(ShellIIDGuid.IShellItem2); var retCode = ShellNativeMethods.SHCreateItemFromIDList(idListPtr, ref guid, out var nativeShellItem); if (!CoreErrorHelper.Succeeded(retCode)) { return(null); } return(ShellObjectFactory.Create(nativeShellItem)); }
/// <summary> /// Constructs a new Shell object from IDList pointer /// </summary> /// <param name="idListPtr"></param> /// <returns></returns> internal static ShellObject Create(IntPtr idListPtr) { // Throw exception if not running on Win7 or newer. CoreHelpers.ThrowIfNotVista(); Guid guid = new Guid(ShellIIDGuid.IShellItem2); IShellItem2 nativeShellItem; int retCode = ShellNativeMethods.SHCreateItemFromIDList(idListPtr, ref guid, out nativeShellItem); if (CoreErrorHelper.Succeeded(retCode)) { return(ShellObjectFactory.Create(nativeShellItem)); } else { // Since this is an internal method, return null instead of throwing an exception. // Let the caller know we weren't able to create a valid ShellObject with the given PIDL return(null); } }