📄 shelllink.c
字号:
TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
return IShellLinkW_GetIDList((IShellLinkW*)&(This->lpvtblw), ppidl);
}
static HRESULT WINAPI IShellLinkA_fnSetIDList(IShellLinkA * iface, LPCITEMIDLIST pidl)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(pidl=%p)\n",This, pidl);
if (This->pPidl)
ILFree(This->pPidl);
This->pPidl = ILClone (pidl);
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetDescription(IShellLinkA * iface, LPSTR pszName,INT cchMaxName)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
if( cchMaxName )
pszName[0] = 0;
if( This->sDescription )
WideCharToMultiByte( CP_ACP, 0, This->sDescription, -1,
pszName, cchMaxName, NULL, NULL);
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetDescription(IShellLinkA * iface, LPCSTR pszName)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(pName=%s)\n", This, pszName);
HeapFree(GetProcessHeap(), 0, This->sDescription);
This->sDescription = HEAP_strdupAtoW( GetProcessHeap(), 0, pszName);
if ( !This->sDescription )
return E_OUTOFMEMORY;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetWorkingDirectory(IShellLinkA * iface, LPSTR pszDir,INT cchMaxPath)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p len=%u)\n", This, pszDir, cchMaxPath);
if( cchMaxPath )
pszDir[0] = 0;
if( This->sWorkDir )
WideCharToMultiByte( CP_ACP, 0, This->sWorkDir, -1,
pszDir, cchMaxPath, NULL, NULL);
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetWorkingDirectory(IShellLinkA * iface, LPCSTR pszDir)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(dir=%s)\n",This, pszDir);
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
This->sWorkDir = HEAP_strdupAtoW( GetProcessHeap(), 0, pszDir);
if ( !This->sWorkDir )
return E_OUTOFMEMORY;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetArguments(IShellLinkA * iface, LPSTR pszArgs,INT cchMaxPath)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p len=%u)\n", This, pszArgs, cchMaxPath);
if( cchMaxPath )
pszArgs[0] = 0;
if( This->sArgs )
WideCharToMultiByte( CP_ACP, 0, This->sArgs, -1,
pszArgs, cchMaxPath, NULL, NULL);
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetArguments(IShellLinkA * iface, LPCSTR pszArgs)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(args=%s)\n",This, pszArgs);
HeapFree(GetProcessHeap(), 0, This->sArgs);
This->sArgs = HEAP_strdupAtoW( GetProcessHeap(), 0, pszArgs);
if( !This->sArgs )
return E_OUTOFMEMORY;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetHotkey(IShellLinkA * iface, WORD *pwHotkey)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p)(0x%08x)\n",This, pwHotkey, This->wHotKey);
*pwHotkey = This->wHotKey;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetHotkey(IShellLinkA * iface, WORD wHotkey)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(hotkey=%x)\n",This, wHotkey);
This->wHotKey = wHotkey;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnGetShowCmd(IShellLinkA * iface, INT *piShowCmd)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p)\n",This, piShowCmd);
*piShowCmd = This->iShowCmd;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetShowCmd(IShellLinkA * iface, INT iShowCmd)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p) %d\n",This, iShowCmd);
This->iShowCmd = iShowCmd;
This->bDirty = TRUE;
return NOERROR;
}
static HRESULT SHELL_PidlGeticonLocationA(IShellFolder* psf, LPITEMIDLIST pidl, LPSTR pszIconPath, int cchIconPath, int* piIcon)
{
LPCITEMIDLIST pidlLast;
HRESULT hr = SHBindToParent(pidl, &IID_IShellFolder, (LPVOID*)&psf, &pidlLast);
if (SUCCEEDED(hr)) {
IExtractIconA* pei;
hr = IShellFolder_GetUIObjectOf(psf, 0, 1, (LPCITEMIDLIST*)&pidlLast, &IID_IExtractIconA, NULL, (LPVOID*)&pei);
if (SUCCEEDED(hr)) {
hr = IExtractIconA_GetIconLocation(pei, 0, pszIconPath, MAX_PATH, piIcon, NULL);
IExtractIconA_Release(pei);
}
IShellFolder_Release(psf);
}
return hr;
}
static HRESULT WINAPI IShellLinkA_fnGetIconLocation(IShellLinkA * iface, LPSTR pszIconPath,INT cchIconPath,INT *piIcon)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(%p len=%u iicon=%p)\n", This, pszIconPath, cchIconPath, piIcon);
pszIconPath[0] = 0;
*piIcon = This->iIcoNdx;
if (This->sIcoPath)
{
WideCharToMultiByte(CP_ACP, 0, This->sIcoPath, -1, pszIconPath, cchIconPath, NULL, NULL);
return S_OK;
}
if (This->pPidl || This->sPath)
{
IShellFolder* pdsk;
HRESULT hr = SHGetDesktopFolder(&pdsk);
if (SUCCEEDED(hr))
{
/* first look for an icon using the PIDL (if present) */
if (This->pPidl)
hr = SHELL_PidlGeticonLocationA(pdsk, This->pPidl, pszIconPath, cchIconPath, piIcon);
else
hr = E_FAIL;
/* if we couldn't find an icon yet, look for it using the file system path */
if (FAILED(hr) && This->sPath)
{
LPITEMIDLIST pidl;
hr = IShellFolder_ParseDisplayName(pdsk, 0, NULL, This->sPath, NULL, &pidl, NULL);
if (SUCCEEDED(hr)) {
hr = SHELL_PidlGeticonLocationA(pdsk, pidl, pszIconPath, cchIconPath, piIcon);
SHFree(pidl);
}
}
IShellFolder_Release(pdsk);
}
return hr;
}
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetIconLocation(IShellLinkA * iface, LPCSTR pszIconPath,INT iIcon)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(path=%s iicon=%u)\n",This, pszIconPath, iIcon);
HeapFree(GetProcessHeap(), 0, This->sIcoPath);
This->sIcoPath = HEAP_strdupAtoW(GetProcessHeap(), 0, pszIconPath);
if ( !This->sIcoPath )
return E_OUTOFMEMORY;
This->iIcoNdx = iIcon;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkA_fnSetRelativePath(IShellLinkA * iface, LPCSTR pszPathRel, DWORD dwReserved)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(path=%s %lx)\n",This, pszPathRel, dwReserved);
HeapFree(GetProcessHeap(), 0, This->sPathRel);
This->sPathRel = HEAP_strdupAtoW(GetProcessHeap(), 0, pszPathRel);
This->bDirty = TRUE;
return ShellLink_UpdatePath(This->sPathRel, This->sPath, This->sWorkDir, &This->sPath);
}
static HRESULT WINAPI IShellLinkA_fnResolve(IShellLinkA * iface, HWND hwnd, DWORD fFlags)
{
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(hwnd=%p flags=%lx)\n",This, hwnd, fFlags);
return IShellLinkW_Resolve( (IShellLinkW*)&(This->lpvtblw), hwnd, fFlags );
}
static HRESULT WINAPI IShellLinkA_fnSetPath(IShellLinkA * iface, LPCSTR pszFile)
{
HRESULT r;
LPWSTR str;
IShellLinkImpl *This = (IShellLinkImpl *)iface;
TRACE("(%p)->(path=%s)\n",This, pszFile);
str = HEAP_strdupAtoW(GetProcessHeap(), 0, pszFile);
if( !str )
return E_OUTOFMEMORY;
r = IShellLinkW_SetPath((IShellLinkW*)&(This->lpvtblw), str);
HeapFree( GetProcessHeap(), 0, str );
return r;
}
/**************************************************************************
* IShellLink Implementation
*/
static const IShellLinkAVtbl slvt =
{
IShellLinkA_fnQueryInterface,
IShellLinkA_fnAddRef,
IShellLinkA_fnRelease,
IShellLinkA_fnGetPath,
IShellLinkA_fnGetIDList,
IShellLinkA_fnSetIDList,
IShellLinkA_fnGetDescription,
IShellLinkA_fnSetDescription,
IShellLinkA_fnGetWorkingDirectory,
IShellLinkA_fnSetWorkingDirectory,
IShellLinkA_fnGetArguments,
IShellLinkA_fnSetArguments,
IShellLinkA_fnGetHotkey,
IShellLinkA_fnSetHotkey,
IShellLinkA_fnGetShowCmd,
IShellLinkA_fnSetShowCmd,
IShellLinkA_fnGetIconLocation,
IShellLinkA_fnSetIconLocation,
IShellLinkA_fnSetRelativePath,
IShellLinkA_fnResolve,
IShellLinkA_fnSetPath
};
/**************************************************************************
* IShellLinkW_fnQueryInterface
*/
static HRESULT WINAPI IShellLinkW_fnQueryInterface(
IShellLinkW * iface, REFIID riid, LPVOID *ppvObj)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
return ShellLink_QueryInterface( This, riid, ppvObj );
}
/******************************************************************************
* IShellLinkW_fnAddRef
*/
static ULONG WINAPI IShellLinkW_fnAddRef(IShellLinkW * iface)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
return ShellLink_AddRef( This );
}
/******************************************************************************
* IShellLinkW_fnRelease
*/
static ULONG WINAPI IShellLinkW_fnRelease(IShellLinkW * iface)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
return ShellLink_Release( This );
}
static HRESULT WINAPI IShellLinkW_fnGetPath(IShellLinkW * iface, LPWSTR pszFile,INT cchMaxPath, WIN32_FIND_DATAW *pfd, DWORD fFlags)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(pfile=%p len=%u find_data=%p flags=%lu)(%s)\n",
This, pszFile, cchMaxPath, pfd, fFlags, debugstr_w(This->sPath));
if (This->sComponent || This->sProduct)
return S_FALSE;
if (cchMaxPath)
pszFile[0] = 0;
if (This->sPath)
lstrcpynW( pszFile, This->sPath, cchMaxPath );
if (pfd) FIXME("(%p): WIN32_FIND_DATA is not yet filled.\n", This);
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnGetIDList(IShellLinkW * iface, LPITEMIDLIST * ppidl)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(ppidl=%p)\n",This, ppidl);
if (!This->pPidl)
return S_FALSE;
*ppidl = ILClone(This->pPidl);
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnSetIDList(IShellLinkW * iface, LPCITEMIDLIST pidl)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(pidl=%p)\n",This, pidl);
if( This->pPidl )
ILFree( This->pPidl );
This->pPidl = ILClone( pidl );
if( !This->pPidl )
return E_FAIL;
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnGetDescription(IShellLinkW * iface, LPWSTR pszName,INT cchMaxName)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(%p len=%u)\n",This, pszName, cchMaxName);
pszName[0] = 0;
if( This->sDescription )
lstrcpynW( pszName, This->sDescription, cchMaxName );
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnSetDescription(IShellLinkW * iface, LPCWSTR pszName)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(desc=%s)\n",This, debugstr_w(pszName));
HeapFree(GetProcessHeap(), 0, This->sDescription);
This->sDescription = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW( pszName )+1)*sizeof(WCHAR) );
if ( !This->sDescription )
return E_OUTOFMEMORY;
lstrcpyW( This->sDescription, pszName );
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnGetWorkingDirectory(IShellLinkW * iface, LPWSTR pszDir,INT cchMaxPath)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(%p len %u)\n", This, pszDir, cchMaxPath);
if( cchMaxPath )
pszDir[0] = 0;
if( This->sWorkDir )
lstrcpynW( pszDir, This->sWorkDir, cchMaxPath );
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnSetWorkingDirectory(IShellLinkW * iface, LPCWSTR pszDir)
{
IShellLinkImpl *This = impl_from_IShellLinkW(iface);
TRACE("(%p)->(dir=%s)\n",This, debugstr_w(pszDir));
HeapFree(GetProcessHeap(), 0, This->sWorkDir);
This->sWorkDir = HeapAlloc( GetProcessHeap(), 0,
(lstrlenW( pszDir )+1)*sizeof (WCHAR) );
if ( !This->sWorkDir )
return E_OUTOFMEMORY;
lstrcpyW( This->sWorkDir, pszDir );
This->bDirty = TRUE;
return S_OK;
}
static HRESULT WINAPI IShellLinkW_fnGetArguments(IShellLinkW * iface, LPWSTR pszArgs,INT cchMaxPath)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -