summaryrefslogtreecommitdiff
path: root/shared/Thumbnail
diff options
context:
space:
mode:
Diffstat (limited to 'shared/Thumbnail')
-rw-r--r--shared/Thumbnail/Thumbnail.vcxproj235
-rw-r--r--shared/Thumbnail/dll_main.cpp25
-rw-r--r--shared/Thumbnail/thumbnail.cpp167
-rw-r--r--shared/Thumbnail/thumbnail.h68
4 files changed, 495 insertions, 0 deletions
diff --git a/shared/Thumbnail/Thumbnail.vcxproj b/shared/Thumbnail/Thumbnail.vcxproj
new file mode 100644
index 00000000..05196e0a
--- /dev/null
+++ b/shared/Thumbnail/Thumbnail.vcxproj
@@ -0,0 +1,235 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <ItemGroup Label="ProjectConfigurations">
+ <ProjectConfiguration Include="Debug|Win32">
+ <Configuration>Debug</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Debug|x64">
+ <Configuration>Debug</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|Win32">
+ <Configuration>Release</Configuration>
+ <Platform>Win32</Platform>
+ </ProjectConfiguration>
+ <ProjectConfiguration Include="Release|x64">
+ <Configuration>Release</Configuration>
+ <Platform>x64</Platform>
+ </ProjectConfiguration>
+ </ItemGroup>
+ <PropertyGroup Label="Globals">
+ <ProjectGuid>{70394AEF-5897-4911-AFA1-82EAF0581EFA}</ProjectGuid>
+ <RootNamespace>ShadowDll</RootNamespace>
+ <Keyword>Win32Proj</Keyword>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <WholeProgramOptimization>true</WholeProgramOptimization>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
+ <CharacterSet>Unicode</CharacterSet>
+ <PlatformToolset>Windows7.1SDK</PlatformToolset>
+ </PropertyGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
+ <ImportGroup Label="ExtensionSettings">
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
+ </ImportGroup>
+ <PropertyGroup Label="UserMacros" />
+ <PropertyGroup>
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">.\</OutDir>
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">OBJ\$(ProjectName)_$(Configuration)_$(Platform)\</IntDir>
+ <LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Thumbnail_$(Platform)</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Thumbnail_$(Platform)</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Thumbnail_$(Platform)</TargetName>
+ <TargetName Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Thumbnail_$(Platform)</TargetName>
+ </PropertyGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ <BuildLog>
+ <Path>$(IntDir)Build.html</Path>
+ </BuildLog>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
+ <DisableSpecificWarnings>4100</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ProfileGuidedDatabase>
+ </ProfileGuidedDatabase>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ <BuildLog>
+ <Path>$(IntDir)Build.html</Path>
+ </BuildLog>
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>Disabled</Optimization>
+ <PreprocessorDefinitions>_DEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <MinimalRebuild>true</MinimalRebuild>
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <DisableSpecificWarnings>4100</DisableSpecificWarnings>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>true</GenerateDebugInformation>
+ <ProgramDatabaseFile>$(IntDir)$(TargetName).pdb</ProgramDatabaseFile>
+ <SubSystem>Windows</SubSystem>
+ <ProfileGuidedDatabase>
+ </ProfileGuidedDatabase>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ <BuildLog>
+ <Path>$(IntDir)Build.html</Path>
+ </BuildLog>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <DisableSpecificWarnings>4100</DisableSpecificWarnings>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+ <ProfileGuidedDatabase>
+ </ProfileGuidedDatabase>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX86</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ <BuildLog>
+ <Path>$(IntDir)Build.html</Path>
+ </BuildLog>
+ <Midl>
+ <TargetEnvironment>X64</TargetEnvironment>
+ </Midl>
+ <ClCompile>
+ <Optimization>MaxSpeed</Optimization>
+ <IntrinsicFunctions>true</IntrinsicFunctions>
+ <PreprocessorDefinitions>NDEBUG;_WINDOWS;_USRDLL;THUMBNAIL_DLL_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
+ <RuntimeLibrary>MultiThreaded</RuntimeLibrary>
+ <FunctionLevelLinking>true</FunctionLevelLinking>
+ <PrecompiledHeader>
+ </PrecompiledHeader>
+ <WarningLevel>Level4</WarningLevel>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
+ <DisableSpecificWarnings>4100</DisableSpecificWarnings>
+ <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
+ </ClCompile>
+ <Link>
+ <OutputFile>$(OutDir)$(TargetName)$(TargetExt)</OutputFile>
+ <SuppressStartupBanner>true</SuppressStartupBanner>
+ <GenerateDebugInformation>false</GenerateDebugInformation>
+ <SubSystem>Windows</SubSystem>
+ <OptimizeReferences>true</OptimizeReferences>
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
+ <LinkTimeCodeGeneration>UseLinkTimeCodeGeneration</LinkTimeCodeGeneration>
+ <ProfileGuidedDatabase>
+ </ProfileGuidedDatabase>
+ <ImportLibrary>$(IntDir)$(TargetName).lib</ImportLibrary>
+ <TargetMachine>MachineX64</TargetMachine>
+ </Link>
+ </ItemDefinitionGroup>
+ <ItemGroup>
+ <ClCompile Include="dll_main.cpp">
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
+ </PrecompiledHeader>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
+ </PrecompiledHeader>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">false</CompileAsManaged>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
+ </PrecompiledHeader>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
+ <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
+ </PrecompiledHeader>
+ <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</CompileAsManaged>
+ </ClCompile>
+ <ClCompile Include="thumbnail.cpp" />
+ </ItemGroup>
+ <ItemGroup>
+ <ClInclude Include="thumbnail.h" />
+ </ItemGroup>
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
+ <ImportGroup Label="ExtensionTargets">
+ </ImportGroup>
+</Project> \ No newline at end of file
diff --git a/shared/Thumbnail/dll_main.cpp b/shared/Thumbnail/dll_main.cpp
new file mode 100644
index 00000000..3805c99d
--- /dev/null
+++ b/shared/Thumbnail/dll_main.cpp
@@ -0,0 +1,25 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+
+
+#define WIN32_LEAN_AND_MEAN
+#include <windows.h>
+
+//optional: add init/teardown logic here
+BOOL APIENTRY DllMain(HINSTANCE hinstDLL,
+ DWORD fdwReason,
+ LPVOID lpvReserved)
+{
+ switch (fdwReason)
+ {
+ case DLL_PROCESS_ATTACH:
+ case DLL_PROCESS_DETACH:
+ case DLL_THREAD_ATTACH:
+ case DLL_THREAD_DETACH:
+ break;
+ }
+ return TRUE;
+}
diff --git a/shared/Thumbnail/thumbnail.cpp b/shared/Thumbnail/thumbnail.cpp
new file mode 100644
index 00000000..51635ff9
--- /dev/null
+++ b/shared/Thumbnail/thumbnail.cpp
@@ -0,0 +1,167 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+
+#include "thumbnail.h"
+
+#define WIN32_LEAN_AND_MEAN
+#include "windows.h"
+
+#define STRICT_TYPED_ITEMIDS //better type safety for IDLists
+#include <Shlobj.h>
+
+#include <Shellapi.h>
+#include <CommonControls.h>
+#include "../com_ptr.h"
+#include "../string_tools.h"
+#include "../loki/ScopeGuard.h"
+//#include "../perf.h"
+
+using namespace zen;
+
+
+thumb::HICON thumb::getThumbnail(const wchar_t* filename, int requestedSize) //return 0 on failure, caller takes ownership!
+{
+ const std::wstring filenameStr(filename);
+
+ util::ComPtr<IShellFolder> shellFolder;
+ {
+ HRESULT hr = ::SHGetDesktopFolder(shellFolder.init());
+ if (FAILED(hr) || !shellFolder)
+ return NULL;
+ }
+
+ PIDLIST_RELATIVE pidlFolder = NULL;
+ {
+ const std::wstring pathName = beforeLast(filenameStr, '\\');
+ HRESULT hr = shellFolder->ParseDisplayName(NULL, // [in] HWND hwnd,
+ NULL, // [in] IBindCtx *pbc,
+ const_cast<LPWSTR>(pathName.c_str()), // [in] LPWSTR pszDisplayName,
+ NULL, // [out] ULONG *pchEaten,
+ &pidlFolder, // [out] PIDLIST_RELATIVE* ppidl,
+ NULL); // [in, out] ULONG *pdwAttributes
+ if (FAILED(hr) || !pidlFolder)
+ return NULL;
+ }
+ LOKI_ON_BLOCK_EXIT2(::ILFree(pidlFolder)); //older version: ::CoTaskMemFree
+
+ util::ComPtr<IShellFolder> imageFolder;
+ {
+ HRESULT hr = shellFolder->BindToObject(pidlFolder, // [in] PCUIDLIST_RELATIVE pidl,
+ NULL,
+ IID_PPV_ARGS(imageFolder.init()));
+ if (FAILED(hr) || !imageFolder)
+ return NULL;
+ }
+
+ PIDLIST_RELATIVE pidImage = NULL;
+ {
+ const std::wstring shortName = afterLast(filenameStr, '\\');
+ HRESULT hr = imageFolder->ParseDisplayName(NULL, // [in] HWND hwnd,
+ NULL, // [in] IBindCtx *pbc,
+ const_cast<LPWSTR>(shortName.c_str()), // [in] LPWSTR pszDisplayName,
+ NULL, // [out] ULONG *pchEaten,
+ &pidImage, // [out] PIDLIST_RELATIVE *ppidl,
+ NULL); // [in, out] ULONG *pdwAttributes
+ if (FAILED(hr) || !pidImage)
+ return NULL;
+ }
+ LOKI_ON_BLOCK_EXIT2(::ILFree(pidImage)); //older version: ::CoTaskMemFree
+
+ util::ComPtr<IExtractImage> extractImage;
+ {
+ PCUITEMID_CHILD_ARRAY pidlIn = reinterpret_cast<PCUITEMID_CHILD_ARRAY>(&pidImage);
+ //this is where STRICT_TYPED_ITEMIDS gets us ;)
+
+ HRESULT hr = imageFolder->GetUIObjectOf(NULL, // [in] HWND hwndOwner,
+ 1, // [in] UINT cidl,
+ pidlIn, // [in] PCUITEMID_CHILD_ARRAY apidl,
+ IID_IExtractImage, // [in] REFIID riid,
+ NULL, // [in, out] UINT *rgfReserved,
+ reinterpret_cast<void**>(extractImage.init())); // [out] void **ppv
+ if (FAILED(hr) || !extractImage)
+ return NULL;
+ }
+
+ {
+ wchar_t pathBuffer[MAX_PATH];
+ DWORD priority = 0;
+ const SIZE prgSize = { requestedSize, requestedSize }; //preferred size only!
+ DWORD clrDepth = 32;
+ DWORD flags = IEIFLAG_SCREEN | IEIFLAG_OFFLINE;
+
+ HRESULT hr = extractImage->GetLocation(pathBuffer, // [out] LPWSTR pszPathBuffer,
+ MAX_PATH, // [in] DWORD cchMax,
+ &priority, // [out] DWORD *pdwPriority,
+ &prgSize, // [in] const SIZE *prgSize,
+ clrDepth, // [in] DWORD dwRecClrDepth,
+ &flags); // [in, out] DWORD *pdwFlags
+ if (FAILED(hr))
+ return NULL;
+ }
+
+ HBITMAP bitmap = NULL;
+ {
+ HRESULT hr = extractImage->Extract(&bitmap);
+ if (FAILED(hr) || !bitmap)
+ return NULL;
+ }
+ LOKI_ON_BLOCK_EXIT2(::DeleteObject(bitmap));
+
+
+ BITMAP bmpInfo = {};
+ if (::GetObject(bitmap, //__in HGDIOBJ hgdiobj,
+ sizeof(bmpInfo), //__in int cbBuffer,
+ &bmpInfo) == 0) //__out LPVOID lpvObject
+ return NULL;
+
+ HBITMAP bitmapMask = ::CreateCompatibleBitmap(::GetDC(NULL), bmpInfo.bmWidth, bmpInfo.bmHeight);
+ if (bitmapMask == 0)
+ return NULL;
+ LOKI_ON_BLOCK_EXIT2(::DeleteObject(bitmapMask));
+
+ ICONINFO iconInfo = {};
+ iconInfo.fIcon = true;
+ iconInfo.hbmColor = bitmap;
+ iconInfo.hbmMask = bitmapMask;
+
+ return ::CreateIconIndirect(&iconInfo);
+}
+
+
+thumb::HICON thumb::getIconByIndex(int iconIndex, int shilIconType) //return 0 on failure, caller takes ownership!
+{
+ //Note: using IExtractIcon::Extract is *no* alternative, just as ::SHGetFileInfo(), it only supports small (16x16) and large (32x32) icons
+
+ util::ComPtr<IImageList> imageList; //perf: 0,12 µs only to get the image list
+ {
+ HRESULT hr = ::SHGetImageList(shilIconType, //__in int iImageList,
+ IID_PPV_ARGS(imageList.init()));
+ if (FAILED(hr) || !imageList)
+ return NULL;
+ }
+
+ bool hasAlpha = false; //perf: 0,14 µs
+ {
+ DWORD flags = 0;
+ HRESULT hr = imageList->GetItemFlags(iconIndex, //[in] int i,
+ &flags); //[out] DWORD *dwFlags
+ if (SUCCEEDED(hr))
+ hasAlpha = flags & ILIF_ALPHA;
+ }
+
+ ::HICON hIcon = NULL; //perf: 1,5 ms - the dominant block
+ {
+ HRESULT hr = imageList->GetIcon(iconIndex, // [in] int i,
+ hasAlpha ? ILD_IMAGE : ILD_NORMAL, // [in] UINT flags,
+ //ILD_IMAGE -> do not draw mask - fixes glitch with ILD_NORMAL where both mask *and* alpha channel are applied, e.g. for ffs_batch and folder icon
+ //other flags: http://msdn.microsoft.com/en-us/library/windows/desktop/bb775230(v=vs.85).aspx
+ &hIcon); // [out] HICON *picon
+ if (FAILED(hr) || !hIcon)
+ return NULL;
+ }
+
+ return hIcon;
+} \ No newline at end of file
diff --git a/shared/Thumbnail/thumbnail.h b/shared/Thumbnail/thumbnail.h
new file mode 100644
index 00000000..ae62cf5d
--- /dev/null
+++ b/shared/Thumbnail/thumbnail.h
@@ -0,0 +1,68 @@
+// **************************************************************************
+// * This file is part of the FreeFileSync project. It is distributed under *
+// * GNU General Public License: http://www.gnu.org/licenses/gpl.html *
+// * Copyright (C) 2008-2011 ZenJu (zhnmju123 AT gmx.de) *
+// **************************************************************************
+
+#ifndef TASKBAR_SEVEN_DLL_H
+#define TASKBAR_SEVEN_DLL_H
+
+#ifdef THUMBNAIL_DLL_EXPORTS
+#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllexport)
+#else
+#define DLL_FUNCTION_DECLARATION extern "C" __declspec(dllimport)
+#endif
+
+#include "../build_info.h"
+//#include <WinDef.h>
+
+namespace thumb
+{
+/*
+PREREQUISITES:
+
+1. COM must be initialized for the current thread via ::CoInitialize(NULL) or ::CoInitializeEx(NULL, COINIT_APARTMENTTHREADED),
+ but NOT ::CoInitializeEx(NULL, COINIT_MULTITHREADED) -> internal access violation crash!
+2. call ::FileIconInit() on app start to remedy obscure errors like SHELL_E_WRONG_BITDEPTH (0x80270102)
+ for certain file types, e.g. lnk, mpg - required on Windows 7 see http://msdn.microsoft.com/en-us/library/ms683212(v=VS.85).aspx
+*/
+
+/*--------------
+ |declarations|
+ --------------*/
+typedef void* HICON;
+
+DLL_FUNCTION_DECLARATION
+HICON getThumbnail(const wchar_t* filename, int requestedSize); //return 0 on failure, caller takes ownership!
+//Note: not all file types support thumbnails! make sure to implement fallback to file icon!
+
+DLL_FUNCTION_DECLARATION
+HICON getIconByIndex(int iconIndex, int shilIconType); //return 0 on failure, caller takes ownership!
+/*
+"iconType" refers to parameter "iImageList" of ::SHGetImageList(); sample values:
+ SHIL_SMALL - 16x16, but the size can be customized by the user.
+ SHIL_EXTRALARGE - 48x48, but the size can be customized by the user.
+ SHIL_JUMBO - Vista and later; normally 256x256 pixels
+"iconIndex" as returned by ::SHGetFileInfo()
+*/
+
+/*----------
+ |typedefs|
+ ----------*/
+typedef HICON (*GetThumbnailFct )(const wchar_t* filename, int requestedSize);
+typedef HICON (*GetIconByIndexFct)(int iconIndex, int shilIconType);
+
+/*--------------
+ |symbol names|
+ --------------*/
+//(use const pointers to ensure internal linkage)
+const char getThumbnailFctName [] = "getThumbnail";
+const char getIconByIndexFctName [] = "getIconByIndex";
+
+/*---------------
+ |library names|
+ ---------------*/
+inline const wchar_t* getDllName() { return util::is64BitBuild ? L"Thumbnail_x64.dll" : L"Thumbnail_Win32.dll"; }
+}
+
+#endif //TASKBAR_SEVEN_DLL_H
bgstack15