Jump to content
GSForum - Segélyvonal

Parancsikon létrehozása


Silent Psycho

Recommended Posts

Silent Psycho

Üdv!

 

Hogyan lehetne létrehozni egy delphiben írt programmal parancsikont?

Például egy gombra rákattintva elhelyezne az asztalon egy parancsikont (az általam megadott ikonnal és névvel), amellyel el lehetne késõbb indítani ezt a programot. Szóval "saját magáról" csinálna parancsikont.

 

:pokolfajzat:

Link to comment
Share on other sites

  • 1 month later...
Guest
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 MySLink do begin
   SetArguments('C:\AUTOEXEC.BAT');
   SetPath(PChar(FileName));
   SetWorkingDirectory(PChar(ExtractFilePath(FileName)));
 end;
 MyReg := TRegIniFile.Create(
   'Software\MicroSoft\Windows\CurrentVersion\Explorer');

// Használd a következõ sort, ha az Asztalra akarod a
// parancsikont létrehozni
 Directory := MyReg.ReadString('Shell Folders','Desktop','');

// Használd a következõ három sort, ha a StartMenübe akarod
// az új parancsikont létrehozni
//  Directory := MyReg.ReadString('Shell Folders','Start Menu','')+
//      '\Whoa!';
//  CreateDir(Directory);

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

end.

Link to comment
Share on other sites

  • 2 weeks later...
Silent Psycho

Köszi!

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...