📄 folders.c
字号:
case DRIVE_RAMDISK: icon_idx = IDI_SHELL_RAMDISK; break;
}
}
if (icon_idx != -1)
{
lstrcpynW(szIconFile, swShell32Name, cchMax);
*piIndex = -icon_idx;
}
else
{
if (HCR_GetDefaultIconW(drive, szIconFile, cchMax, &dwNr))
{
*piIndex = dwNr;
}
else
{
lstrcpynW(szIconFile, swShell32Name, cchMax);
*piIndex = -IDI_SHELL_DRIVE;
}
}
}
else if (_ILIsFolder (pSimplePidl))
{
getIconLocationForFolder(iface, uFlags, szIconFile, cchMax, piIndex,
pwFlags);
}
else
{
BOOL found = FALSE;
if (_ILIsCPanelStruct(pSimplePidl))
{
if (SUCCEEDED(CPanel_GetIconLocationW(pSimplePidl, szIconFile, cchMax, piIndex)))
found = TRUE;
}
else if (_ILGetExtension(pSimplePidl, sTemp, MAX_PATH))
{
if (HCR_MapTypeToValueA(sTemp, sTemp, MAX_PATH, TRUE)
&& HCR_GetDefaultIconA(sTemp, sTemp, MAX_PATH, &dwNr))
{
if (!lstrcmpA("%1", sTemp)) /* icon is in the file */
{
SHGetPathFromIDListW(This->pidl, szIconFile);
*piIndex = 0;
}
else
{
MultiByteToWideChar(CP_ACP, 0, sTemp, -1, szIconFile, cchMax);
*piIndex = dwNr;
}
found = TRUE;
}
else if (!lstrcmpiA(sTemp, "lnkfile"))
{
/* extract icon from shell shortcut */
IShellFolder* dsf;
IShellLinkW* psl;
if (SUCCEEDED(SHGetDesktopFolder(&dsf)))
{
HRESULT hr = IShellFolder_GetUIObjectOf(dsf, NULL, 1, (LPCITEMIDLIST*)&This->pidl, &IID_IShellLinkW, NULL, (LPVOID*)&psl);
if (SUCCEEDED(hr))
{
hr = IShellLinkW_GetIconLocation(psl, szIconFile, MAX_PATH, piIndex);
if (SUCCEEDED(hr) && *szIconFile)
found = TRUE;
IShellLinkW_Release(psl);
}
IShellFolder_Release(dsf);
}
}
}
if (!found) /* default icon */
{
lstrcpynW(szIconFile, swShell32Name, cchMax);
*piIndex = 0;
}
}
TRACE("-- %s %x\n", debugstr_w(szIconFile), *piIndex);
return NOERROR;
}
/**************************************************************************
* IExtractIconW_Extract
*/
static HRESULT WINAPI IExtractIconW_fnExtract(IExtractIconW * iface, LPCWSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
{
IExtractIconWImpl *This = (IExtractIconWImpl *)iface;
int index;
FIXME("(%p) (file=%p index=%d %p %p size=%08x) semi-stub\n", This, debugstr_w(pszFile), (signed)nIconIndex,
phiconLarge, phiconSmall, nIconSize);
index = SIC_GetIconIndex(pszFile, nIconIndex, 0);
if (phiconLarge)
*phiconLarge = ImageList_GetIcon(ShellBigIconList, index, ILD_TRANSPARENT);
if (phiconSmall)
*phiconSmall = ImageList_GetIcon(ShellSmallIconList, index, ILD_TRANSPARENT);
return S_OK;
}
static const IExtractIconWVtbl eivt =
{
IExtractIconW_fnQueryInterface,
IExtractIconW_fnAddRef,
IExtractIconW_fnRelease,
IExtractIconW_fnGetIconLocation,
IExtractIconW_fnExtract
};
/**************************************************************************
* IExtractIconA_Constructor
*/
IExtractIconA* IExtractIconA_Constructor(LPCITEMIDLIST pidl)
{
IExtractIconWImpl *This = (IExtractIconWImpl *)IExtractIconW_Constructor(pidl);
IExtractIconA *eia = (IExtractIconA *)&This->lpvtblExtractIconA;
TRACE("(%p)->(%p)\n", This, eia);
return eia;
}
/**************************************************************************
* IExtractIconA_QueryInterface
*/
static HRESULT WINAPI IExtractIconA_fnQueryInterface(IExtractIconA * iface, REFIID riid, LPVOID *ppvObj)
{
IExtractIconW *This = impl_from_IExtractIconA(iface);
return IExtractIconW_QueryInterface(This, riid, ppvObj);
}
/**************************************************************************
* IExtractIconA_AddRef
*/
static ULONG WINAPI IExtractIconA_fnAddRef(IExtractIconA * iface)
{
IExtractIconW *This = impl_from_IExtractIconA(iface);
return IExtractIconW_AddRef(This);
}
/**************************************************************************
* IExtractIconA_Release
*/
static ULONG WINAPI IExtractIconA_fnRelease(IExtractIconA * iface)
{
IExtractIconW *This = impl_from_IExtractIconA(iface);
return IExtractIconW_AddRef(This);
}
/**************************************************************************
* IExtractIconA_GetIconLocation
*
* mapping filetype to icon
*/
static HRESULT WINAPI IExtractIconA_fnGetIconLocation(
IExtractIconA * iface,
UINT uFlags,
LPSTR szIconFile,
UINT cchMax,
int * piIndex,
UINT * pwFlags)
{
HRESULT ret;
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, cchMax * sizeof(WCHAR));
IExtractIconW *This = impl_from_IExtractIconA(iface);
TRACE("(%p) (flags=%u %p %u %p %p)\n", This, uFlags, szIconFile, cchMax, piIndex, pwFlags);
ret = IExtractIconW_GetIconLocation(This, uFlags, lpwstrFile, cchMax, piIndex, pwFlags);
WideCharToMultiByte(CP_ACP, 0, lpwstrFile, -1, szIconFile, cchMax, NULL, NULL);
HeapFree(GetProcessHeap(), 0, lpwstrFile);
TRACE("-- %s %x\n", szIconFile, *piIndex);
return ret;
}
/**************************************************************************
* IExtractIconA_Extract
*/
static HRESULT WINAPI IExtractIconA_fnExtract(IExtractIconA * iface, LPCSTR pszFile, UINT nIconIndex, HICON *phiconLarge, HICON *phiconSmall, UINT nIconSize)
{
HRESULT ret;
INT len = MultiByteToWideChar(CP_ACP, 0, pszFile, -1, NULL, 0);
LPWSTR lpwstrFile = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
IExtractIconW *This = impl_from_IExtractIconA(iface);
TRACE("(%p) (file=%p index=%u %p %p size=%u)\n", This, pszFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
MultiByteToWideChar(CP_ACP, 0, pszFile, -1, lpwstrFile, len);
ret = IExtractIconW_Extract(This, lpwstrFile, nIconIndex, phiconLarge, phiconSmall, nIconSize);
HeapFree(GetProcessHeap(), 0, lpwstrFile);
return ret;
}
static const IExtractIconAVtbl eiavt =
{
IExtractIconA_fnQueryInterface,
IExtractIconA_fnAddRef,
IExtractIconA_fnRelease,
IExtractIconA_fnGetIconLocation,
IExtractIconA_fnExtract
};
/************************************************************************
* IEIPersistFile_QueryInterface (IUnknown)
*/
static HRESULT WINAPI IEIPersistFile_fnQueryInterface(
IPersistFile *iface,
REFIID iid,
LPVOID *ppvObj)
{
IExtractIconW *This = impl_from_IPersistFile(iface);
return IExtractIconW_QueryInterface(This, iid, ppvObj);
}
/************************************************************************
* IEIPersistFile_AddRef (IUnknown)
*/
static ULONG WINAPI IEIPersistFile_fnAddRef(
IPersistFile *iface)
{
IExtractIconW *This = impl_from_IPersistFile(iface);
return IExtractIconW_AddRef(This);
}
/************************************************************************
* IEIPersistFile_Release (IUnknown)
*/
static ULONG WINAPI IEIPersistFile_fnRelease(
IPersistFile *iface)
{
IExtractIconW *This = impl_from_IPersistFile(iface);
return IExtractIconW_Release(This);
}
/************************************************************************
* IEIPersistFile_GetClassID (IPersist)
*/
static HRESULT WINAPI IEIPersistFile_fnGetClassID(
IPersistFile *iface,
LPCLSID lpClassId)
{
CLSID StdFolderID = { 0x00000000, 0x0000, 0x0000, {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00} };
if (lpClassId==NULL)
return E_POINTER;
memcpy(lpClassId, &StdFolderID, sizeof(StdFolderID));
return S_OK;
}
/************************************************************************
* IEIPersistFile_Load (IPersistFile)
*/
static HRESULT WINAPI IEIPersistFile_fnLoad(IPersistFile* iface, LPCOLESTR pszFileName, DWORD dwMode)
{
IExtractIconW *This = impl_from_IPersistFile(iface);
FIXME("%p\n", This);
return E_NOTIMPL;
}
static const IPersistFileVtbl pfvt =
{
IEIPersistFile_fnQueryInterface,
IEIPersistFile_fnAddRef,
IEIPersistFile_fnRelease,
IEIPersistFile_fnGetClassID,
(void *) 0xdeadbeef /* IEIPersistFile_fnIsDirty */,
IEIPersistFile_fnLoad,
(void *) 0xdeadbeef /* IEIPersistFile_fnSave */,
(void *) 0xdeadbeef /* IEIPersistFile_fnSaveCompleted */,
(void *) 0xdeadbeef /* IEIPersistFile_fnGetCurFile */
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -