0

I created in C++ an internet shortcut for windows in the start menu. Everything is fine, but how can i add a tooltip to this shortcut?

I could not find somethink like I ShellLink::SetDescription for shell links.

...
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();
  }
}
...
infingy
  • 33
  • 4
  • *"an internet shortcut for windows in the start menu"* I have no idea what you're trying to describe here. – Cody Gray - on strike Aug 01 '14 at 12:58
  • In windows you have a start menu and in there you can put links/shortcuts also to a url. – infingy Aug 01 '14 at 13:05
  • Hmm, okay. So what was wrong with [IShellLink:SetDescription](http://msdn.microsoft.com/en-us/library/windows/desktop/bb774955.aspx)? That's exactly what it's for: shell links. – Cody Gray - on strike Aug 01 '14 at 13:16
  • Well you cannot use IShellLink to create a link to a URL. http://msdn.microsoft.com/en-us/library/windows/desktop/bb776891(v=vs.85).aspx So i used IUniformResourceLocator – infingy Aug 01 '14 at 13:20

1 Answers1

0

You can query an IUniformResourceLocator for its IPropertySetStorage interface and then set additional properties through that.

Internet Shortcuts | Accessing Property Storage

The Internet shortcut object contains several properties that you can access through the object's IPropertySetStorage interface
...
The following property IDs can be requested for FMTID_Intshcut.

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

You can also query an IUniformResourceLocator for its IShellLink interface and set those properties as well.

Internet Shortcuts | Interfaces

The Internet shortcut object exposes a number of interfaces.

OLE interfaces
IDataObject
IPersistFile
IPersistStream
IOleCommandTarget
IPropertySetStorage
IObjectWithSite

Shell interfaces
IContextMenu2
IExtractIcon
INewShortcutHook
IShellExtInit
IShellLink
IShellPropSheetExt
IQueryInfo

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Rejoyed too soon! I was able to change the url with IPropertySetStorage but not the tooltip. PID_IS_DESCRIPTION and others did not work. – infingy Aug 04 '14 at 12:04