如何制作uninstall卸载图标(50分)

  • 主题发起人 主题发起人 kenan_2001
  • 开始时间 开始时间
K

kenan_2001

Unregistered / Unconfirmed
GUEST, unregistred user!
我想在开始-程序-制作uninstall快捷图标,不知如何来,没定其指定的路径!
 
我也想知道,帮你提前吧[:D]
 
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
Form1: TForm1;

implementation

{$R *.DFM}

uses
ShlObj, ActiveX, ComObj, Registry;

procedure TForm1.Button1Click(Sender: TObject);
var
MyObject : IUnknown;
MySLink : IShellLink;
MyPFile : IPersistFile;
FileName : String;
Directory : String;
WFileName : WideString;
MyReg : TRegIniFile;
begin

MyObject := CreateComObject(CLSID_ShellLink);
MySLink := MyObject as IShellLink;
MyPFile := MyObject as IPersistFile;
FileName := 'NOTEPAD.EXE';
with MySLinkdo
begin

SetArguments('C:/AUTOEXEC.BAT');
SetPath(PChar(FileName));
SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
end;

MyReg := TRegIniFile.Create(
'Software/MicroSoft/Windows/CurrentVersion/Explorer');

// Use the next line of code to put the shortcut on your desktop
// Directory := MyReg.ReadString('Shell Folders','Desktop','');

// Use the next three lines to put the shortcut on your start menu
Directory := MyReg.ReadString('Shell Folders','Start Menu','');
// '/Whoa!';
// CreateDir(Directory);

WFileName := Directory+'/FooBar.lnk';
MyPFile.Save(PWChar(WFileName),False);
MyReg.Free;
end;


end.

// 如果要得到快捷文件的属性,则先应调用IPersistFile对象的Load,然后调用IShellLink的GetPath等函数以获得各种属性(详见Win32 API帮助)。如:
// Load .lnk file
WFileName := ExpandFileName(Sr.Name);
MyPFile.Load(PWChar(WFileName), STGM_DIRECT);

// Retrieve the hotkey.
MySLink.GetHotKey(wHotKey);

// Retrieve the icon.
MySLink.GetIconLocation(Filename, 255, nIndex);
if strLen(Filename) <> 0 then

begin

MyIcon := TIcon.Create;
MyIcon.Handle := ExtractIcon(hInstance, Filename, nIndex);
ListItem.ImageIndex := frmMain.ImageList1.AddIcon(MyIcon);
MyIcon.Free;
end
else

begin

MySLink.GetPath(Filename, 255, fd, SLGP_UNCPRIORITY);
MyIcon := TIcon.Create;
nIndex2 := 0;
MyIcon.Handle := ExtractAssociatedIcon(hInstance, Filename, nIndex2);
ListItem.ImageIndex := frmMain.ImageList1.AddIcon(MyIcon);
MyIcon.Free;
end;
 
后退
顶部