pidl) = error_success then
'调用“添加到收藏夹”对话框
'hwnd = 本窗口的句柄
'szpath = 所选择文件夹的绝对路径,包括文件名和所需的url
' 例如,在我的系统里就是c:\documents and settings\40star\favorites\csdn.net--中国最大的开发者网络.url
'sztitle = 标题
'pidl = pidl 描述用户的收藏夹的信息
success = doaddtofavdlg(hwnd, _
szpath, nsizeofpath, _
sztitle, nsizeoftitle, _
pidl)
'如果路径有效并指定了标题,而且用户选择了“确定”,success 返回 1
if success = 1 then
'删除最后的chr$(0)
pos = instr(szpath, chr$(0))
szpath = left(szpath, pos - 1)
pos = instr(sztitle, chr$(0))
sztitle = left(sztitle, pos - 1)
'在text中显示结果
text1.text = szpath
text2.text = sztitle
call profilesaveitem("internetshortcut", "url", surl, szpath)
'返回创建成功的路径
makefavouriteentry = szpath
end if
'清空pidl
call cotaskmemfree(pidl)
end if
end function
public sub profilesaveitem(lpsectionname as string, _
lpkeyname as string, _
lpvalue as string, _
inifile as string)
call writeprivateprofilestring(lpsectionname, lpkeyname, lpvalue, inifile)
end sub
private function getfolderpath(csidl as long) as string
dim spath as string
dim stmp as string
spath = space$(max_path)
if shgetfolderpath(me.hwnd, _
csidl, _
0&, _
shgfp_type_current, _
spath) = s_ok then
getfolderpath = left$(spath, instr(spath, chr$(0)) - 1)
end if
end function