用delphi怎样生成 .lnk文件(各种快捷方式文件)
---------------------------------------------
我要向桌面生成一个我用delphi写的应用程序的快捷图标方式 ,需要用到.lnk文件
---------------------
我应该怎样做
-----------------
期待您的回应!

解决方案 »

  1.   

    procedure TForm3.Button3Click(Sender: TObject);
    var
      filename:string;
      AnObj: IUnknown;
      ShLink: IShellLink;
      PFile: IPersistFile;
      WFileName: WideString;
      Reg: TRegIniFile;
    begin
      if form3.CheckBox1.Checked then
      begin
        AnObj := CreateComObject (CLSID_ShellLink);
        ShLink := AnObj as IShellLink;
        PFile := AnObj as IPersistFile;
        filename:=extractfilepath(application.ExeName)+'表格管理过程控制\表格管理过程控制.exe';
        ShLink.SetPath (PChar (FileName));
        ShLink.SetWorkingDirectory (PChar(ExtractFilePath (FileName)));
        Reg := TRegIniFile.Create('Software\MicroSoft\Windows\CurrentVersion\Explorer');
        WFileName := Reg.ReadString ('Shell Folders', 'Desktop', '') +'\' +'表格管理过程控制.lnk';
        Reg.Free;
        PFile.Save (PWChar (WFileName), False);
      end;
      application.Terminate;
    end;