下面是个超简单的在delphi中建立程序的快捷方式--并将快捷方式放在开始->程序-教程,图老师小编精心挑选推荐,大家行行好,多给几个赞吧,小编吐血跪求~
【 tulaoshi.com - 编程语言 】
前几天应客户要求写这个东西,其实用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上的内容
来源:http://www.tulaoshi.com/n/20160219/1601912.html
看过《在delphi中建立程序的快捷方式--并将快捷方式放在开始->程序-》的人还看了以下文章 更多>>