我用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();
}
}
...
您可以查询IUniformResourceLocator
的IPropertySetStorage
接口,然后通过该接口设置其他属性。
Internet快捷方式|访问属性存储
Internet快捷方式对象包含几个属性,您可以通过对象的IPropertySetStorage接口访问这些属性
…
以下属性id可以请求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
您也可以查询IUniformResourceLocator
的IShellLink
接口并设置这些属性。
Internet快捷方式|接口
Internet快捷方式对象公开了许多接口。
OLE接口IDataObject
IPersistFile
IPersistStream
IOleCommandTarget
IPropertySetStorage
IObjectWithSite壳界面
IContextMenu2
IExtractIcon
INewShortcutHook
IShellExtInit
IShellLink
IShellPropSheetExt
IQueryInfo