吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3191|回复: 1
收起左侧

[其他转载] 创建程序桌面快捷方式

  [复制链接]
codebutcher 发表于 2013-4-1 15:06
本帖最后由 codebutcher 于 2013-4-1 15:11 编辑

//本例程以创建Internet Explorer桌面快捷方式为例
//Delphi XE3 With Update2编译通过
//以创建Internet Explorer快捷方式到桌面为例
unit Unit1;
interface
uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs,ShlObj, ActiveX, ComObj, Vcl.StdCtrls;
type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject) ;
var
    IObject : IUnknown;
    ISLink : IShellLink;
    IPFile : IPersistFile;
    PIDL : PItemIDList;
    InFolder : array[0..MAX_PATH] of Char;
    TargetName : String;
    LinkName : WideString;
begin
    TargetName := 'C:\Program Files\Internet Explorer\iexplore.exe';
    {Use TargetName:=ParamStr(0) which
    returns the path and file name of the
    executing program to create a link to your
    Application}
    IObject := CreateComObject(CLSID_ShellLink) ;
    ISLink := IObject as IShellLink;
    IPFile := IObject as IPersistFile;
    with ISLink do
    begin
      SetPath(pChar(TargetName)) ;
      SetWorkingDirectory(pChar(ExtractFilePath(TargetName))) ;
    end;
    // if we want to place a link on the Desktop
    SHGetSpecialFolderLocation(0, CSIDL_DESKTOPDIRECTORY, PIDL) ;
    SHGetPathFromIDList(PIDL, InFolder) ;
    {
     or if we want a link to appear in
     some other, not-so-special, folder:
     InFolder := 'C:\SomeFolder'
    }
    LinkName := InFolder + '\Internet Explorer.lnk';
    IPFile.Save(PWChar(LinkName), false) ;
    Button1.Enabled:=false;
end;
end.













免费评分

参与人数 1热心值 +1 收起 理由
淡然出尘 + 1 我很赞同!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

淡然出尘 发表于 2013-4-1 15:30
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-9-21 19:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表