Home resolving network shortcut
Reply: 1

resolving network shortcut

Tahtu Published in 2017-09-13 09:05:19Z

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.

Anders Reply to 2017-09-13 12:15:31Z

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.

You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.329414 second(s) , Gzip On .

© 2016 Powered by cudou.com design MATCHINFO