在delphi中建立程序的快捷方式--并将快捷方式放在开始->程序->的启动组中
2006-02-04 13:48:26 来源:WEB开发网前几天应客户要求写这个东西,其实用VB,VC可能更快些,不过,我还是喜欢用DELPHI
首先 uses ActiveX,ComObj,StdCtrls,ShlObj,FileCtrl;
在指定文件夹建立当前应用程序才的快捷方式
PRocedure Tform1.MakeLink(Foldername:string;proName, lnkName, Description: string);
var
WorkDir, DestName: string;
aObj: IUnknown;
MyLink: IShellLink;
MyPFile: IPersistFile;
WFileName: WideString;
curdir: array[0..100] of Char;
begin
DestName := Foldername + lnkName;
aObj := CreateComObject(CLSID_ShellLink);
MyLink := aObj as IShellLink;
MyPFile := aObj as IPersistFile;
GetCurrentDirectory(sizeof(curdir), curdir);
workdir := curdir;
proname := trim(WorkDir)+'\'+proname;
with MyLink do
begin
SetShowCmd(SW_NORMAL);
SetArguments('');
SetDescription(pChar(Description));
SetPath(pChar(proName));
SetWorkingDirectory(pChar(WorkDir));
end;
CreateDir(ExtractFilePath(DestName));
WFileName := DestName;
MyPFile.Save(PWChar(WFileName), False);
end;
//获得开始->程序->的启动组 的路径
function Tform1.GetSpecialFolder: string;//get starup Floder
var
Pidl: PItemIDList;
handle : THandle;
Comp: TComponent;
LinkDir : string;
begin
result:='';
Comp := self;//self.owner;
handle := (Comp as TForm).handle;
if SUCCEEDED(SHGetSpecialFolderLocation(handle, CSIDL_COMMON_STARTUP, Pidl)) then //别的特殊路径也可以用CSIDL_COMMON或的,在delphi中查一下就可以了
begin
SetLength(LinkDir, MAX_PATH);
SHGetPathFromIDList(Pidl, PChar(LinkDir));
SetLength(LinkDir, StrLen(PChar(LinkDir)));
result:=linkdir+'\';
end;
end;
//部分内容借鉴了大富翁bbs上的内容
- ››程序员 不妨都写一写前端代码
- ››Delphi实现把10进制转换成16进制的函数进制转化
- ››Delphi中将字符串按给定字符分隔(似split函数功能...
- ››Delphi 动态创建窗体,锁定窗口赋值
- ››Delphi 与 VC 共享接口和对象
- ››Delphi图像处理 -- 表面模糊
- ››建立唯美图片特效,十个jQuery插件分享
- ››Delphi之多线程实例
- ››Delphi SelectSingleNode的使用 根据节点属性获取...
- ››Delphi接口详述
- ››delphi 远程调试
- ››Delphi与DirectX之DelphiX(34): TDIB.Lightness()...
更多精彩
赞助商链接