⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 runoncep.dpr

📁 Delphi Win32核心API参考光盘源码 本书包含了常用的Windows API函数
💻 DPR
字号:
program RunOnceP;

uses
  Forms,
  Windows,
  Dialogs,
  RunOnceU in 'RunOnceU.pas' {Form1};

{$R *.res}

var
  MutexHandle: Integer;

begin
  {attempt to open a handle to the mutex. if this function is successful,
   we know that the application has already started, and we can terminate}
  if OpenMutex(MUTEX_ALL_ACCESS, FALSE, 'RunOnceMutex') <> 0 then
  begin
    ShowMessage('This application is already open!');
    Exit;
  end;

  {if we get here, we are the first instance of this application, so
   create the mutex and immediately acquire ownership of it}
  MutexHandle := CreateMutex(nil, TRUE, 'RunOnceMutex');

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

  {now that we are done, we must release the mutex}
  ReleaseMutex(MutexHandle);
end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -