unit uSC;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComObj, ActiveX, ShlObj, Registry;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
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
AnObj: IUnknown;
ShLink: IShellLink;
PFile: IPersistFile;
FileName: string;
WFileName: WideString;
Reg: TRegIniFile;
begin
AnObj := CreateComObject(CLSID_ShellLink);
ShLink := AnObj as IShellLink;
//or 'ShLink := CreatComObject(CLSID_ShellLink) as IShellLink;'
PFile := AnObj as IPersistFile;
FileName := ParamStr(0);
ShLink.SetPath(PChar(FileName));
ShLink.SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
if CheckBox1.Checked then
begin
WFileName := ExtractFilePath(FileName) + Edit1.Text + '.lnk';
PFile.Save(PWChar(WFileName), false);
end;
if CheckBox2.Checked then
begin
Reg := TRegIniFile.Create('Software/Microsoft/Windows/CurrentVersion/Explorer');
WFileName := Reg.ReadString('Shell Folders', 'Desktop', 'not find')
+ '/' + Edit1.Text + '.lnk';
Reg.Free;
PFile.Save(PWChar(WFileName), false);
end;
if CheckBox3.Checked then
begin
Reg := TRegIniFile.Create('Software/Microsoft/Windows/CurrentVersion/Explorer');
WFileName := Reg.ReadString('Shell Folders', 'Start Menu', '')
+ '/' + Edit1.Text + '.lnk';
Reg.Free;
PFile.Save(PWChar(WFileName), false);
end;
end;
end.
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ComObj, ActiveX, ShlObj, Registry;
type
TForm1 = class(TForm)
Label1: TLabel;
Edit1: TEdit;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
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
AnObj: IUnknown;
ShLink: IShellLink;
PFile: IPersistFile;
FileName: string;
WFileName: WideString;
Reg: TRegIniFile;
begin
AnObj := CreateComObject(CLSID_ShellLink);
ShLink := AnObj as IShellLink;
//or 'ShLink := CreatComObject(CLSID_ShellLink) as IShellLink;'
PFile := AnObj as IPersistFile;
FileName := ParamStr(0);
ShLink.SetPath(PChar(FileName));
ShLink.SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
if CheckBox1.Checked then
begin
WFileName := ExtractFilePath(FileName) + Edit1.Text + '.lnk';
PFile.Save(PWChar(WFileName), false);
end;
if CheckBox2.Checked then
begin
Reg := TRegIniFile.Create('Software/Microsoft/Windows/CurrentVersion/Explorer');
WFileName := Reg.ReadString('Shell Folders', 'Desktop', 'not find')
+ '/' + Edit1.Text + '.lnk';
Reg.Free;
PFile.Save(PWChar(WFileName), false);
end;
if CheckBox3.Checked then
begin
Reg := TRegIniFile.Create('Software/Microsoft/Windows/CurrentVersion/Explorer');
WFileName := Reg.ReadString('Shell Folders', 'Start Menu', '')
+ '/' + Edit1.Text + '.lnk';
Reg.Free;
PFile.Save(PWChar(WFileName), false);
end;
end;
end.