Silent Psycho 0 Share Posted June 9, 2005 Ü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. Link to comment Share on other sites More sharing options...
Guest Share Posted July 23, 2005 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 More sharing options...
Silent Psycho 0 Author Share Posted August 4, 2005 Köszi! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now