public TimeSpan DurationOfMediaFile(string FilePath) { Version v = Environment.OSVersion.Version; // WIN7 APIs if (Environment.OSVersion.Version >= new Version(6, 1)) { using (ShellFile sf = ShellFile.FromFilePath(FilePath)) { ShellProperties props = sf.Properties; ShellProperties.PropertySystem psys = props.System; ulong?duration = psys.Media.Duration.Value; if (duration.HasValue) { return(TimeSpan.FromTicks((long)duration.Value)); } } } else { // LEGACY *** (XP and Vista) LegacyMediaDuration lmd = new LegacyMediaDuration(); return(lmd.GetMediaDuration(FilePath)); } return(TimeSpan.FromSeconds(0)); }
/// <summary> /// Release the native and managed objects /// </summary> /// <param name="disposing">Indicates that this is being called from Dispose(), rather than the finalizer.</param> protected virtual void Dispose(bool disposing) { if (disposing) { internalName = null; internalParsingName = null; properties = null; thumbnail = null; parentShellObject = null; } if (internalPIDL != IntPtr.Zero) { ShellNativeMethods.ILFree(internalPIDL); internalPIDL = IntPtr.Zero; } if (nativeShellItem != null) { Marshal.ReleaseComObject(nativeShellItem); nativeShellItem = null; } if (NativePropertyStore != null) { Marshal.ReleaseComObject(NativePropertyStore); NativePropertyStore = null; } }
protected static int GetIntegerValue(ShellProperties properties, PropertyKey key) { var result = properties.GetProperty <uint?>(key).Value; if (result == null) { return(0); } return((int)result.Value); }
protected static string GetStringValue(ShellProperties properties, PropertyKey key) { var result = properties.GetProperty <string>(key)?.Value; if (result == null) { var result2 = properties.GetProperty <string[]>(key)?.Value; result = result2?.First(); } return(result ?? string.Empty); }
} // private void ReadFileDetails(string path) { using (ShellObject shellObj = ShellObject.FromParsingName(path)) { using (ShellProperties props = shellObj.Properties) { this.WriteProperties(props); IShellProperty shellProp = props.GetProperty(SystemProperties.System.Category); ShellPropertyDescription desc = SystemProperties.GetPropertyDescription(SystemProperties.System.Category); Console.WriteLine("Prop value: " + desc.ValueType); } } }
private void PopulateShellFileInfo(string fullPath) { try { if (!ShellFile.IsPlatformSupported) { return; } using (var timer = new TimingMetrics(TimingMetric.GettingShellInfo)) { using (ShellFile file = ShellFile.FromFilePath(fullPath)) { using (ShellProperties fileProperties = file.Properties) { ShellProperties.PropertySystem shellProperty = fileProperties.System; Project = shellProperty.Project.Value ?? ""; ProviderItemID = shellProperty.ProviderItemID.Value ?? ""; OriginalFileName = shellProperty.OriginalFileName.Value ?? ""; FileOwner = shellProperty.FileOwner.Value ?? ""; FileVersion = shellProperty.FileVersion.Value ?? ""; FileDescription = shellProperty.FileDescription.Value ?? ""; Trademarks = shellProperty.Trademarks.Value ?? ""; Link = shellProperty.Link.TargetUrl.Value ?? ""; Copyright = shellProperty.Copyright.Value ?? ""; Company = shellProperty.Company.Value ?? ""; ApplicationName = shellProperty.ApplicationName.Value ?? ""; Comment = shellProperty.Comment.Value ?? ""; Title = shellProperty.Title.Value ?? ""; CancellationHelper.ThrowIfCancelled(); MimeType = shellProperty.ContentType.Value ?? ""; InternalName = shellProperty.InternalName.Value ?? ""; ProductName = shellProperty.Software.ProductName.Value ?? ""; Language = shellProperty.Language.Value ?? ""; ComputerName = shellProperty.ComputerName.Value ?? ""; } } } } catch { } }
/// <summary> /// Adds an area section to the application. /// </summary> /// <param name="uniqueName">Name of the unique area.</param> /// <param name="properties">The properties.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> /// <exception cref="CSiException"><see cref="CSiApiBase.API_DEFAULT_ERROR_CODE" /></exception> public bool AddShell(string uniqueName, ShellProperties properties) { return(add(uniqueName, properties, Shell.Add)); }
private void WriteProperties(ShellProperties properties) { } //
protected static bool GetBoolValue(ShellProperties properties, PropertyKey key) { var result = properties.GetProperty <bool?>(key).Value; return(result != null && result.Value); }