como executar somente 1 copia do programa
ola amigos.. como eu faço pra executar somente 1 copia do programa compilado??
[]´s
[]´s
Njuniorba
Curtidas 0
Respostas
Ipc$
18/03/2006
No seu .dpr:
1-Adicione na cláusula [b:431babe36c]uses[/b:431babe36c]: Windows, Dialogs;
Depois:
1-Adicione na cláusula [b:431babe36c]uses[/b:431babe36c]: Windows, Dialogs;
Depois:
var hMutex:THandle; begin hMutex := 0; try hMutex := CreateMutex(nil, true, PChar(´Meu Programa´)); if GetLastError = ERROR_ALREADY_EXISTS then begin ShowMessage(´Meu Programa Já Está em Execução!´); CloseHandle(hMutex); end else begin Application.Initialize; Application.CreateForm(TForm1, Form1); Application.Run; end; finally ReleaseMutex(hMutex); end; end.
GOSTEI 0
Paullsoftware
18/03/2006
ou então pode tentar assim:
:wink:
var aberto : HWND; begin aberto := FindWindow(nil,PChar(´CroLan - Gerenciamento de Lan-Houses´)); if aberto = 0 then begin Application.Initialize; Application.Title := ´CroLan - Gerenciamento de Lan-Houses´; Application.CreateForm(TfMenu, fMenu); Application.CreateForm(TDM, DM); Application.Run; end; end else begin ShowMessage(´Sistema já está em uso!´); Application.Terminate; end;
:wink:
GOSTEI 0
Rjun
18/03/2006
Faça uma pesquisa no fórum sobre MUTEX.
GOSTEI 0