-
Notifications
You must be signed in to change notification settings - Fork 5
/
Win32.Interop.cs
41 lines (34 loc) · 1.56 KB
/
Win32.Interop.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Runtime.InteropServices;
using System.Runtime.InteropServices.ComTypes;
namespace Microsoft.Win32.Interop
{
class Shell
{
[StructLayout(LayoutKind.Sequential)]
public struct SHFILEINFO
{
public IntPtr hIcon;
public IntPtr iIcon;
public uint dwAttributes;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 260)]
public string szDisplayName;
[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 80)]
public string szTypeName;
};
public const uint SHGFI_ICON = 0x100;
public const uint SHGFI_LARGEICON = 0x0; // Large icon
public const uint SHGFI_SMALLICON = 0x1; // Small icon
public const uint FILE_ATTRIBUTE_NORMAL = 0x00000080;
public const uint STGM_DELETEONRELEASE = 0x04000000;
public const uint STGM_SHARE_DENY_WRITE = 0x00000020;
public const uint STGM_SHARE_DENY_NONE = 0x00000040;
public const uint STGM_READ = 0x00000000;
[DllImport("user32.dll")]
public static extern bool DestroyIcon(IntPtr handle);
[DllImport("shlwapi.dll", CharSet = CharSet.Unicode, ExactSpelling = true, PreserveSig = false, EntryPoint = "SHCreateStreamOnFileW")]
public static extern void SHCreateStreamOnFile(string fileName, uint mode, ref IStream stream);
[DllImport("shell32.dll")]
public static extern IntPtr SHGetFileInfo(string pszPath, uint dwFileAttributes, ref SHFILEINFO psfi, uint cbSizeFileInfo, uint uFlags);
}
}