bestlong 怕失憶論壇's Archiver

bestlong 發表於 2012-12-19 17:32

防止應用程式重複執行(使用 JEDI JCL JVCL)

在 JEDI JVCL 有提供元件,在元件盤 Jv System 內有 JvAppInstances 元件,加入到主 Form 中就可以了

不過使用 JVCL 元件程式還是建立了主視窗,還有另一個法寶可以在應用程式初始化前就處理
可以使用 JCL 的 JclAppInst 類別
只要引入 JclAppInst 與執行一行檢查程式 JclAppInstances.CheckSingleInstance 就可以了[code]
program Project1;

uses
  Forms,
  JclAppInst,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.RES}

begin
  JclAppInstances.CheckSingleInstance;
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.
[/code]真的超簡單

關於 JCL 的用法是在下列網頁中看到了
Solnone 螺旋旅人 [url=http://solnone.blogspot.tw/2009/05/delphi-jedi-singleinstance.html]Delphi JEDI SingleInstance (單一執行程式)[/url]
頁: [1]

Powered by Discuz! X1.5 Archiver   © 2001-2010 Comsenz Inc.