Esempio n. 1
0
 private DefaultBrowser(String exePath, IconIdentifierType iconIdentifierType, Int32?identifier, String iconFile)
 {
     this.ExePath            = exePath;
     this.IconIdentifierType = iconIdentifierType;
     this.Identifier         = identifier;
     this.IconFile           = iconFile;
 }
Esempio n. 2
0
        public IconResourceBag(Int32 identifier, IconIdentifierType identifierType, [NotNull] Icon icon)
        {
            if (icon == null)
            {
                throw new ArgumentNullException(nameof(icon));
            }

            this.Identifier     = identifier;
            this.Icon           = icon;
            this.IdentifierType = identifierType;
        }
Esempio n. 3
0
        public static String RetrieveAssociatedIcon([NotNull] String extensionOrFileOrProtocol, [CanBeNull] out Int32?identifier, out IconIdentifierType identifierType)
        {
            if (String.IsNullOrWhiteSpace(extensionOrFileOrProtocol))
            {
                throw new ArgumentNullException(nameof(extensionOrFileOrProtocol));
            }

            identifier     = null;
            identifierType = IconIdentifierType.Unknown;

            // Special case: The result buffer contains "%1". We treat this case like: "oh hey, your supplied file path is already the file containing the icon!".
            var result = SafeNativeMethods.AssocQueryString(extensionOrFileOrProtocol, NativeMethods.ASSOCSTR.ASSOCSTR_DEFAULTICON);

            if (result == "%1")
            {
                return(String.Empty);
            }

            if (result.IndexOf(',') == -1)
            {
                identifier     = 0;
                identifierType = IconIdentifierType.Index;
                return(result);
            }

            Int32 extractedIdentifier;
            var   file = NativeResourceDescriptor.SplitResourceString(result, out extractedIdentifier);

            identifier     = extractedIdentifier;
            identifierType = IconIdentifier.Identify(extractedIdentifier);
            return(file);
        }