0

我用 C++ 在开始菜单中为 Windows 创建了一个 Internet 快捷方式。一切都很好,但我怎样才能向这个快捷方式添加工具提示?

我找不到类似于 ShellLink::SetDescription 的 shell 链接。

...
QString internetAddress = "http://www.blabla.de";
IUniformResourceLocator *pURL = NULL;

CoInitialize(NULL);
HRESULT hres;
hres = CoCreateInstance(CLSID_InternetShortcut, NULL,
  CLSCTX_INPROC_SERVER, IID_IUniformResourceLocator, (LPVOID*)&pURL);
if(SUCCEEDED(hres))
{
  IPersistFile *ppf = NULL;

  hres = pURL->SetURL((LPCWSTR)internetAddress.utf16(), 0);

  if(SUCCEEDED(hres))
  {
    hres = pURL->QueryInterface(IID_IPersistFile, (LPVOID*)&ppf);
    if(SUCCEEDED(hres))
    {
      hres = ppf->Save((LPCWSTR)linkFilePath.utf16(), TRUE);

      ppf->Release();
    }
    pURL->Release();
  }
}
...
4

1 回答 1

0

您可以查询 anIUniformResourceLocatorIPropertySetStorage接口,然后通过它设置其他属性。

互联网捷径 | 访问属性存储

Internet 快捷方式对象包含几个属性,您可以通过对象的 IPropertySetStorage 接口访问这些属性
...
可以为 FMTID_Intshcut 请求以下属性 ID。

PROPID      Variant Type    Description
PID_IS_URL      VT_LPWSTR   URL to which the shortcut leads
PID_IS_NAME     VT_LPWSTR   Name of the Internet shortcut
PID_IS_WORKINGDIR   VT_LPWSTR   Working directory for the shortcut
PID_IS_HOTKEY   VT_UI2  Hotkey for the shortcut
PID_IS_SHOWCMD  VT_I4   Show command for shortcut
PID_IS_ICONINDEX    VT_I4   Index of the icon
PID_IS_ICONFILE VT_LPWSTR   File that contains the icon
PID_IS_WHATSNEW VT_LPWSTR   What's New text
PID_IS_AUTHOR   VT_LPWSTR   Author
PID_IS_DESCRIPTION  VT_LPWSTR   Description text of site
PID_IS_COMMENT  VT_LPWSTR   User annotated comment
PID_IS_ROAMED   VT_BOOL True when shortcut is roamed for first time

您还可以查询 anIUniformResourceLocatorIShellLink接口并设置这些属性。

互联网捷径 | 接口

Internet 快捷方式对象公开了许多接口。

OLE 接口
IDataObject
IPersistFile
IPersistStream
IOleCommandTarget
IPropertySetStorage
IObjectWithSite

Shell 接口
IContextMenu2
IExtractIcon
INewShortcutHook
IShellExtInit
IShellLink
IShellPropSheetExt
IQueryInfo

于 2014-08-01T16:29:43.240 回答