Windows with Delphi Windows API (94) Windows Filesystem (41) Windows Forms (69) Windows Graphics (38)
Exchange Links About this site Links to us 
|
Allow only one instance of a program (works also under NT)
This article has not been rated yet. After reading, feel free to leave comments and rate it.
Just add this unit to your uses clause
uses Single;
and your program will not be started twice:
 | |  | | unit Single;
interface
implementation
uses Windows, SysUtils;
var hnd: THandle;
initialization
hnd := CreateMutex(nil, True, 'irgendwaseinmaliges');
if GetLastError = ERROR_ALREADY_EXISTS then Halt;
finalization
if hnd <> 0 then CloseHandle(hnd);
end.
| |  | |  | You don't like the formatting? Check out SourceCoder then!
Comments:
|