Skip to content

Commit

Permalink
Add ExtractIcon() and ExtractIconEx().
Browse files Browse the repository at this point in the history
  • Loading branch information
nmlgc committed Dec 21, 2014
1 parent c3d1e5a commit 614b2e9
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 0 deletions.
34 changes: 34 additions & 0 deletions src/shell32_dll.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@

const w32u8_pair_t shell32_pairs[] = {
{"DragQueryFileA", DragQueryFileU},
{"ExtractIconA", ExtractIconU},
{"ExtractIconExA", ExtractIconExU},
{"SHBrowseForFolderA", SHBrowseForFolderU},
{"SHGetPathFromIDListA", SHGetPathFromIDListU},
NULL
Expand Down Expand Up @@ -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.
Expand Down
18 changes: 18 additions & 0 deletions src/shell32_dll.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
);
Expand Down
2 changes: 2 additions & 0 deletions win32_utf8.def
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ EXPORTS
; shell32.dll
; -----------
DragQueryFileU
ExtractIconU
ExtractIconExU
SHBrowseForFolderU
SHGetPathFromIDListU

Expand Down

0 comments on commit 614b2e9

Please sign in to comment.