델파이 초보자라서 SetForegroundWindow 적용이 안되는 부분 해결을 못했다. ㅜㅜ

적용전
program HttpDown;

uses
  Forms,
  FmHDMain in 'FmHDMain.pas' {Form1};

{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.


적용후
program HttpDown;

uses
  Forms,
  SysUtils,
  Windows,
  Mutex in 'Mutex.pas',
  FmHDMain in 'FmHDMain.pas' {Form1};

{$R *.res}

const
  MutexName = 'JmLaunch';

var
  hMutex: HWND;
  ClassNames: array[0..0] of PAnsiChar = (
    'TFrmLMain'
  );

begin
  if Mutex.CheckMutex(MutexName) then
  begin
    Mutex.SetActiveWindows(ClassNames, SizeOf(ClassNames) div 4);
    Exit;
  end;

  try
    hMutex := Mutex.CreateSecurityMutex(MutexName);
    if hMutex = 0 then
    begin
      raise Exception.Create('Mutex 생성 실패');
    end;

    try
      Application.Initialize;
      Application.CreateForm(TForm1, Form1);
      Application.Run;
    finally
      ReleaseMutex(hMutex);
    end;
  except
    on E: Exception do Application.ShowException(E);
  end;
end.

'Windows > RAD Studio' 카테고리의 다른 글

[RAD] GExpert - Debug 창 이용하기  (0) 2007.10.01
[JS] ScrollObject  (0) 2007.09.21
[CB] Mutex 를 이용한 실행중복 방지  (0) 2007.09.10
[CB] KeyPad Virtual Key Value  (0) 2007.06.09
[DEL] Deprecated Lists  (0) 2007.06.02

+ Recent posts