Can anyone tell me how to retreive a shortcut's target? I don't want to read it from the lnk file itself so I thought about com objects... :shock:
Posted on 2004-08-27 02:24:52 by Dom

I'm not totally sure but you can do:

- create an IShellLink object
- query that object for IPersistFile
- Call IPersistFile::Load with the path of the .LNK file
- call IShellLink::GetPath to get the path of the target
Posted on 2004-08-27 02:36:31 by japheth
well, actually i need the whole target (path + executeable)
Posted on 2004-08-27 03:01:16 by Dom


Retrieves the path and file name of a shell link object.

LPSTR pszFile,
int cchMaxPath,
DWORD fFlags

Address of a buffer that receives the path and file name of the shell link object.
Maximum number of bytes to copy to the buffer pointed to by the pszFile parameter.
Address of a WIN32_FIND_DATA structure that contains information about the shell link object.
Flags that specify the type of path information to retrieve. This parameter can be a combination of the following values: Flag Description
SLGP_SHORTPATH Retrieves the standard short (8.3 format) file name.
SLGP_UNCPRIORITY Retrieves the Universal Naming Convention (UNC) path name of the file.
SLGP_RAWPATH Retrieves the raw path name. A raw path is something that might not exist and may include environment variables that need to be expanded.

Return Values
Returns NOERROR if the operation is successful, and a valid path is retrieved. If the operation is successful, but no path is retrieved, it returns S_FALSE and pszPath will be empty. Otherwise, it returns an OLE-defined error value.

See Also

Version 4.00 and later of Shell32.dll

Windows NT/2000: Requires Windows NT 4.0 or later.
Windows 95/98: Requires Windows 95 or later.
Header: Declared in shlobj.h.

Posted on 2004-08-27 07:15:57 by japheth
ok i got it...GetPath is my function. :wink:
Posted on 2004-08-27 07:33:19 by Dom