c ++ windows开始菜单互联网捷径工具提示

时间:2014-08-01 12:51:06

标签: c++ windows startmenu

我在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();
  }
}
...

1 个答案:

答案 0 :(得分:0)

您可以在IUniformResourceLocator查询其IPropertySetStorage界面,然后通过该界面设置其他属性。

Internet Shortcuts | Accessing Property Storage

  

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

您还可以查询IUniformResourceLocatorIShellLink界面并设置这些属性。

Internet Shortcuts | Interfaces

  

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

     

OLE接口
  IDataObject的
  IPersistFile
  IPersistStream接口
  IOleCommandTarget
  的 IPropertySetStorage
  的IObjectWithSite

     

Shell接口
  IContextMenu2
  IExtractIcon
  INewShortcutHook
  IShellExtInit
  的的IShellLink
  IShellPropSheetExt
  IQueryInfo