Skip to content

Instantly share code, notes, and snippets.

@smourier
Created September 29, 2025 07:35
Show Gist options
  • Save smourier/27fd1c55a0e4e4eacb8d896572d1f8b3 to your computer and use it in GitHub Desktop.
Save smourier/27fd1c55a0e4e4eacb8d896572d1f8b3 to your computer and use it in GitHub Desktop.
Demonstrates GetThumbnailCutoffFromType
static void Main()
{
// init system image list or GetThumbnailCutoffFromType will always return 20 (default value)
SHGetImageList(0, new Guid("46eb5926-582e-4017-9fdf-e8998daa0950"), out var imgList); // IID_IImageList
Marshal.Release(imgList);
var video = GetThumbnailCutoffFromType("video");
Console.WriteLine(video); // 16
var folder = GetThumbnailCutoffFromType("folder");
Console.WriteLine(folder); // 32
var png = GetThumbnailCutoffFromType(".png");
Console.WriteLine(png); // 20
var mix = GetThumbnailCutoffFromType(".mix");
Console.WriteLine(mix); // 20
}
[DllImport("windows.storage.dll", CharSet = CharSet.Unicode)]
private static extern int GetThumbnailCutoffFromType(string type);
[DllImport("shell32.dll")]
private static extern int SHGetImageList(int iImageList, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, out nint ppvObj);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment