call "window.external.addFavorite"
Posted: Tue May 04, 2004 6:33 am
Code: Select all
;call "window.external.addFavorite"
Procedure addfavorite(link.s,linkname.s)
;linkname to "COleVariant" ???
;link in unicode
mem.s = Space(1000)
MultiByteToWideChar_(#CP_ACP, 0, link, -1, mem, 1000)
CoInitialize_(0)
If CoCreateInstance_(?CLSID_ShellUIHelper,0,1,?IID_IShellUIHelper,@Object.IShellUIHelper) = 0
Object\AddFavorite(@mem,@linkname);
Object\Release()
EndIf
CoUninitialize_()
DataSection
CLSID_ShellUIHelper:
Data.l $64AB4BB7
Data.w $111E,$11D1
Data.b $8F,$79,$00,$C0,$4F,$C2,$FB,$E1
IID_IShellUIHelper:
Data.l $729FE2F8
Data.w $1EA8,$11D1
Data.b $8F,$85,$00,$C0,$4F,$C2,$FB,$E1
EndDataSection
EndProcedure
addfavorite("http://www.purebasic.com","your linkname")
End
#include "ExDisp.h"
IShellUIHelper* pShell = NULL;
HRESULT hr = CoCreateInstance(CLSID_ShellUIHelper, NULL, CLSCTX_SERVER,
IID_IShellUIHelper, (void**)&pShell);
if (hr == S_OK)
{
COleVariant vtTitle("Microsoft");
pShell->AddFavorite(OLESTR("http://www.microsoft.com"), &vtTitle);
pShell->Release();
}