Uzun zaman dan beri merak ettigim bir şeyi bugün yaptım
bu kadar basit olacagını hiç düsünmemiştim
ve sizlerle paylaşmak istedim
programımızı acarken degişik parametrelerle acmak
yani masa üstüne ekledigimiz kısayol şöyle iken
Kod: Tümünü seç
C:\delphi_deneme\AKL_LOG_KAYIT\AFT_MAIN.exe
Kod: Tümünü seç
C:\delphi_deneme\AKL_LOG_KAYIT\AFT_MAIN.exe \A
Project1 {projenin adı}
Unit1 Form1
Unit2 Form2
Unit3 Form3
delphi project menüsünden View Source yi tıklayalım
ve kaynak kodu asagıdaki gibi düzenleyelim
Kod: Tümünü seç
program Project1;
uses
Forms,
SysUtils,
Windows,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2},
Unit3 in 'Unit3.pas' {Form3};
{$R *.res}
var
s: string;
begin
Application.Initialize;
s := UpperCase(ParamStr(1));
if pos('/A', s) > 0 then
begin
Application.CreateForm(TForm1, Form1);
end
else if pos('/B', s) > 0 then
begin
Application.CreateForm(TForm2, Form2);
end
else if pos('/C', s) > 0 then
begin
Application.CreateForm(TForm3, Form3);
end
else
begin { Parametre yoksa default formu acın }
Application.CreateForm(TForm1, Form1);
{ Veya programı sonlandırın }
//Application.Terminate
end;
Application.Run;
end.
NOT:Bu işlem sart degil program içinden test etmek içindir.
Kod: Tümünü seç
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
S: string;
begin
S := Application.ExeName;
Application.Terminate;
WinExec(PChar(S + ' /A'), SW_SHOWNORMAL);
end;
procedure TForm1.Button2Click(Sender: TObject);
var
S: string;
begin
S := Application.ExeName;
Application.Terminate;
WinExec(PChar(S + ' /B'), SW_SHOWNORMAL);
end;
procedure TForm1.Button3Click(Sender: TObject);
var
S: string;
begin
S := Application.ExeName;
Application.Terminate;
WinExec(PChar(S + ' /C'), SW_SHOWNORMAL);
end;
end.
Ayrıca masaüstüne bu program için 3 tane kısayol olusturup linklerini düzenleyin
bendeki Path bu C:\delphi_deneme\Delphi_Test\
sizdeki gibi düzenleyin
// C:\delphi_deneme\Delphi_Test\Project1.exe /A
// C:\delphi_deneme\Delphi_Test\Project1.exe /B
// C:\delphi_deneme\Delphi_Test\Project1.exe /C
ve test edin her kısayol programı farklı bir form ile acacak
ben örnek olsun diye form actırıyorum siz baska procedure ler işletirsiniz artık.
NOT:Bu örnekleme Delphi7 de Test edildi.
sevgiler.