在控件中操作程序实例不是一个好的设计方案,你可以将文件名作为一个参数传入你实现某项功能的方法即可,比如:
TMyControl = class
public
procedure DoFileOperate(AFileName: string);
end;
{ TMyControl }
procedure TMyControl.DoFileOperate(AFileName: string);
begin
//Do File Operation
end;
使用时:
procedure TForm1.Button1Click(Sender: TObject);
begin
with TMyControl.Create do
try
DoFileOperate(Application.ExeName);
finally
Free;
end;
end;