From 614b2e9e7ecb5507284252096f59eb3b9f4494ec Mon Sep 17 00:00:00 2001 From: nmlgc Date: Sun, 21 Dec 2014 21:43:47 +0100 Subject: [PATCH] Add ExtractIcon() and ExtractIconEx(). --- src/shell32_dll.c | 34 ++++++++++++++++++++++++++++++++++ src/shell32_dll.h | 18 ++++++++++++++++++ win32_utf8.def | 2 ++ 3 files changed, 54 insertions(+) diff --git a/src/shell32_dll.c b/src/shell32_dll.c index 3591e91..9c8e777 100644 --- a/src/shell32_dll.c +++ b/src/shell32_dll.c @@ -13,6 +13,8 @@ const w32u8_pair_t shell32_pairs[] = { {"DragQueryFileA", DragQueryFileU}, + {"ExtractIconA", ExtractIconU}, + {"ExtractIconExA", ExtractIconExU}, {"SHBrowseForFolderA", SHBrowseForFolderU}, {"SHGetPathFromIDListA", SHGetPathFromIDListU}, NULL @@ -55,6 +57,38 @@ UINT WINAPI DragQueryFileU( return ret; } +HICON WINAPI ExtractIconU( + __reserved HINSTANCE hInst, + __in LPCSTR lpszExeFileName, + __in UINT nIconIndex +) +{ + HICON ret; + WCHAR_T_DEC(lpszExeFileName); + WCHAR_T_CONV_VLA(lpszExeFileName); + ret = ExtractIconW(hInst, lpszExeFileName_w, nIconIndex); + WCHAR_T_FREE(lpszExeFileName); + return ret; +} + +UINT WINAPI ExtractIconExU( + LPCSTR lpszFile, + int nIconIndex, + __out_ecount_opt(nIcons) HICON *phiconLarge, + __out_ecount_opt(nIcons) HICON *phiconSmall, + UINT nIcons +) +{ + UINT ret; + WCHAR_T_DEC(lpszFile); + WCHAR_T_CONV_VLA(lpszFile); + ret = ExtractIconExW( + lpszFile_w, nIconIndex, phiconLarge, phiconSmall, nIcons + ); + WCHAR_T_FREE(lpszFile); + return ret; +} + // CoGetApartmentType() is not available prior to Windows 7, but luckily, // http://msdn.microsoft.com/en-us/library/windows/desktop/dd542641%28v=vs.85%29.aspx // describes a way how to get the same functionality on previous systems. diff --git a/src/shell32_dll.h b/src/shell32_dll.h index 110a48c..9b0f2c6 100644 --- a/src/shell32_dll.h +++ b/src/shell32_dll.h @@ -17,6 +17,24 @@ UINT WINAPI DragQueryFileU( #undef DragQueryFile #define DragQueryFile DragQueryFileU +HICON WINAPI ExtractIconU( + __reserved HINSTANCE hInst, + __in LPCSTR lpszExeFileName, + __in UINT nIconIndex +); +#undef ExtractIcon +#define ExtractIcon ExtractIconU + +UINT WINAPI ExtractIconExU( + LPCSTR lpszFile, + int nIconIndex, + __out_ecount_opt(nIcons) HICON *phiconLarge, + __out_ecount_opt(nIcons) HICON *phiconSmall, + UINT nIcons +); +#undef ExtractIconEx +#define ExtractIconEx ExtractIconExU + PIDLIST_ABSOLUTE WINAPI SHBrowseForFolderU( __in LPBROWSEINFOA lpbi ); diff --git a/win32_utf8.def b/win32_utf8.def index ba54be6..e7c106b 100644 --- a/win32_utf8.def +++ b/win32_utf8.def @@ -62,6 +62,8 @@ EXPORTS ; shell32.dll ; ----------- DragQueryFileU + ExtractIconU + ExtractIconExU SHBrowseForFolderU SHGetPathFromIDListU