怎样在桌面上创建Internet快捷方式?

Ivan_pan 2004-04-20 09:10:43
怎样在桌面上创建Internet快捷方式?
...全文
156 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
hch_45 2004-04-20
  • 打赏
  • 举报
回复
uses ShellAPI, ShlObj, ActiveX, ComObj;

const
CCH_MAXNAME=255;
LNK_RUN_MIN=7;
LNK_RUN_MAX=3;
LNK_RUN_NORMAL=1;
type
LINK_FILE_INFO=record
FileName:array[0..MAX_PATH] of char;
WorkDirectory:array[0..MAX_PATH] of char;
IconLocation:array[0..MAX_PATH] of char;
IconIndex:integer;
Arguments:array[0..MAX_PATH] of char;
Description:array[0..CCH_MAXNAME] of char;
ItemIDList:PItemIDList;
RelativePath:array[0..255] of char;
ShowState:integer;
HotKey:word;
end;

function CreateLinkFile(const info:LINK_FILE_INFO;const DestFileName:string=''):boolean;
var
anobj:IUnknown;
shlink:IShellLink;
pFile:IPersistFile;
wFileName:widestring;
begin
wFileName:=destfilename;
anobj:=CreateComObject(CLSID_SHELLLINK);
shlink:=anobj as IShellLink;
pFile:=anobj as IPersistFile;
shlink.SetPath(info.FileName);
shlink.SetWorkingDirectory(info.WorkDirectory);
shlink.SetDescription(info.Description);
shlink.SetArguments(info.Arguments);
shlink.SetIconLocation(info.IconLocation,info.IconIndex);
shlink.SetHotkey(info.HotKey);
shlink.SetShowCmd(info.ShowState);
shlink.SetRelativePath(info.RelativePath,0);
if DestFileName='' then
wFileName:=ChangeFileExt(info.FileName,'lnk');
result:=succeeded(pFile.Save(pwchar(wFileName),false));
end;


procedure TForm1.Button1Click(Sender: TObject);
var
rLnk : LINK_FILE_INFO;
pidl:pItemIDList;
pDesktop : string;
begin
rLnk.FileName := 'C:\Program Files\Internet Explorer\IEXPLORE.EXE';
rLnk.WorkDirectory := 'C:\Program Files\Internet Explorer\';
rLnk.IconIndex := 0;

//取桌面路径
SetLength(pDesktop, 255);
SHGetSpecialFolderLocation(Self.Handle, CSIDL_DESKTOP, pidl);
SHGetPathFromIDList(pidl, PChar(pDesktop));
SetLength(pDesktop, StrLen(PChar(pDesktop)));

CreateLinkFile(rLnk, pDesktop + '\' + 'I.lnk');
end;
visual_cjiajia 2004-04-20
  • 打赏
  • 举报
回复
shellapi

1,183

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧