Team Ai
Datasetpublic

MegaBites-AI/Windows-powershell

sourceHugging Facemitupdated 6mo agoView on Hugging Face
0likes372downloads
SHGetFileInfo.cs39 linesDownload Raw Back to Windows
1// Copyright (c) Microsoft Corporation.2// Licensed under the MIT License.3 4#nullable enable5 6using System.Diagnostics.CodeAnalysis;7using System.Runtime.InteropServices;8 9internal static partial class Interop10{11    [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1305:FieldNamesMustNotUseHungarianNotation", Justification = "Keep native struct names.")]12    [SuppressMessage("StyleCop.CSharp.NamingRules", "SA1307:AccessibleFieldsMustBeginWithUpperCaseLetter", Justification = "Keep native struct names.")]13    internal static partial class Windows14    {15        [StructLayout(LayoutKind.Sequential)]16        internal unsafe struct SHFILEINFO17        {18            internal nint hIcon;19            internal int iIcon;20            internal uint dwAttributes;21            internal fixed char szDisplayName[260];22            internal fixed char szTypeName[80];23 24            public static readonly uint s_Size = (uint)sizeof(SHFILEINFO);25        }26 27        [LibraryImport("shell32.dll", EntryPoint = "SHGetFileInfoW", StringMarshalling = StringMarshalling.Utf16)]28        internal static partial nint SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);29 30        internal static int SHGetFileInfo(string pszPath)31        {32            // flag used to ask to return exe type33            const uint SHGFI_EXETYPE = 0x000002000;34            var shinfo = new SHFILEINFO();35            return (int)SHGetFileInfo(pszPath, 0, ref shinfo, SHFILEINFO.s_Size, SHGFI_EXETYPE);36        }37    }38}39