Replace DllImport with LibraryImport in SMA 4 (#18579)

This commit is contained in:
Ilya authored and GitHub committed 2022-11-23 09:11:52 +05:00
1 parent ea428a6e1f
commit 5b4a34fcc9
2 files changed
+42 -35

No files matched your search

@@ -1106,10 +1106,9 @@ namespace System.Management.Automation
return false;
}
SHFILEINFO shinfo = new SHFILEINFO();
IntPtr type = SHGetFileInfo(fileName, 0, ref shinfo, (uint)Marshal.SizeOf(shinfo), SHGFI_EXETYPE);
int type = Interop.Windows.SHGetFileInfo(fileName);
switch ((int)type)
switch (type)
{
case 0x0:
// 0x0 = not an exe
@@ -1640,38 +1639,6 @@ namespace System.Management.Automation
#endregion
#region Interop for SHGetFileInfo
private const int SCS_32BIT_BINARY = 0; // A 32-bit Windows-based application
private const int SCS_DOS_BINARY = 1; // An MS-DOS - based application
private const int SCS_WOW_BINARY = 2; // A 16-bit Windows-based application
private const int SCS_PIF_BINARY = 3; // A PIF file that executes an MS-DOS - based application
private const int SCS_POSIX_BINARY = 4; // A POSIX - based application
private const int SCS_OS216_BINARY = 5; // A 16-bit OS/2-based application
private const int SCS_64BIT_BINARY = 6; // A 64-bit Windows-based application.
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Unicode)]
private struct SHFILEINFO
{
public IntPtr hIcon;
public int iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
}
private const uint SHGFI_EXETYPE = 0x000002000; // flag used to ask to return exe type
[DllImport("shell32.dll", CharSet = CharSet.Unicode)]
private static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes,
ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
#endregion
#region Minishell Interop
private bool _isMiniShell = false;