Subscribe:

Ads 468x60px

Loading

Senin, 04 Juli 2011

Delphi Run App One Instance

Just Modify your Project Source code as below :

program Project1;

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

{$R *.RES}

var
   hMapping      :THandle;
begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  hMapping := CreateFileMapping( THANDLE($ffffffff),
                                 NIL,
                                 PAGE_READONLY,
                                 0,
                                 32,
                                 'MyTestMap' );
   if( hMapping>0 ) then
     if( GetLastError() = ERROR_ALREADY_EXISTS ) then
      begin
         Application.Terminate;
      end
   else
     Application.run;

end.

0 komentar:

Posting Komentar