Du kan også bruge Mutex.
function IsAppRunning: BOOL;
var
fHandle: HWND;
begin
fHandle:= CreateMutex(nil,False,PChar(Application.Title)); // Check if application has been launched?
try
result:= GetLastError = ERROR_ALREADY_EXISTS; // is current application running?
// well, if you don't like this message, you can write your own error message...
if result then
begin
ShowMessage('File Launcher is already running!');
CloseHandle(fHandle); // Handles are memory eaters, so get rid-off second copy...
end;
finally
ReleaseMutex(fHandle); // make sure free mutex.
end;
end;
I formCreate skriver du
begin
if not IsAppRunning then
else
Application.Terminate;
end
-------------------------------------------------------
Jonas (Decko)
http://www.growyourownshit.com/users/Decko-------------------------------------------------------