I added some FTP servers via network shortcuts to windows.
How can I get the FTP address via the WinAPI?
With SHGetFolderPath / CSIDL_NETHOOD, I can get the location of the target.lnk file. But how can I get the FTP URL of that file?
A "normal" .lnk file, I can resolve with this:
ShellLink := CreateComObject(CLSID_ShellLink) as IShellLink;
ShellLink.QueryInterface(IPersistFile, PersistFile);
PersistFile.Load('C:\Test.lnk', STGM_READ);
ShellLink.Resolve(WindowHandle, 0);
Filename[0] := #0;
ShellLink.GetPath(PChar(@Filename[0]), Length(Filename), pfd, 0);
... but this does not work for the Target.lnk files of the network shortcuts to ftp://host/ adresses.
IShellLink::GetPath
is used to retrieve a file system path (only drive letter or UNC roots). This is not clear from the documentation but it uses SHGetPathFromIDListEx
internally and MSDN has this to say about that function:
Converts an item identifier list to a file system path
If you want the raw shortcut target your best bet is usually IShellLink::GetIDList
. You can get the parsing name by using SHGetNameFromIDList(..., SIGDN_DESKTOPABSOLUTEPARSING, ...)
on the id-list.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.