CreateMutex

    技术2024-12-23  10

    { *.dpr } {$R *.res} var hMutex: THandle; const NameMutex = 'MyMutex'; begin if OpenMutex(MUTEX_ALL_ACCESS, False, NameMutex) <> 0 then //uses windows begin MessageBox(0, '该程序已启动', '提示', MB_OK); Application.Terminate; end; hMutex := CreateMutex(nil, False, NameMutex); Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; CloseHandle(hMutex); end.

    最新回复(0)