GetAppPathFromLink

Go to Home Page

Returns the target of a .lnk shortcut link

Syntax

HRESULT WINAPI GetAppPathFromLink (
    IShellItem* pItem,
    LPWSTR pwszPathBuffer,
    DWORD dwBufferLen
)

Parameters

pItem
IShellItem interface representing the link shortcut file
pwszPathBuffer
A pointer to the buffer that will receive the target of the link
dwBufferLen
Size of pwszPathBuffer in characters

Return Value

S_OK is the function succeeds, standard COM error code otherwise

Remarks

You can use SHCreateShellItem, SHCreateItemWithParent, SHCreateItemFromIDList, SHCreateItemFromParsingName or SHCreateItemFromRelativeName to create an IShellItem.

pItem can also be an IShellItem2.

pItem is queried for a IShellLinkW interface by means of IShellItem::BindToHandler(NULL, BHID_SFUIObject, IID_PPV_ARGS(&pShellLinkW)) which is used to get the path.