解决网络快捷方式

解决网络快捷方式

本文介绍了解决网络快捷方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我通过网络快捷方式向Windows添加了一些FTP服务器。

I added some FTP servers via network shortcuts to windows.

如何通过WinAPI获取FTP地址?

How can I get the FTP address via the WinAPI?

使用SHGetFolderPath / CSIDL_NETHOOD,我可以获取target.lnk文件的位置。但是,如何获取该文件的FTP URL?

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?

一个普通 .lnk文件,可以通过以下方式解决:

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);

...但这不适用于 ftp:// host / 地址。

... but this does not work for the Target.lnk files of the network shortcuts to ftp://host/ adresses.

推荐答案

IShellLink :: GetPath 用于检索文件系统路径(仅驱动器号或UNC根)。从文档中尚不清楚,但是它在内部使用 SHGetPathFromIDListEx ,而MSDN对此功能的说法如下:

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:

如果您想使用原始快捷方式作为最佳选择通常是 IShellLink :: GetIDList 。您可以使用在id列表上。

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.

这篇关于解决网络快捷方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-10 22:43