限制.exe只有一个在运行解决方法

限制.exe只有一个在运行大家好!我现在用delphi做了一个.exe文件,要使我的.exe文件只打开一个,当打开第二个

限制.exe只有一个在运行
大家好!我现在用delphi做了一个.exe文件,要使我的.exe文件只打开一个,当打开第二个时,要提示“该.exe文件已经打开”请教大家该怎么限制!!不胜感激

[解决办法]

Delphi(Pascal) code
var   ret   :integer;             hMutex:=CreateMutex(nil,False,'宏达第三方维护软件');         ret:=GetLastError;         if   Ret<>ERROR_ALREADY_EXISTS   then         begin         Application.CreateForm(TFrmMain,   FrmMain);         FrmSplash.Show;         FrmSplash.Update;         Application.Run;         end         else           Application.MessageBox('   已经启动,不能再次运行本程序!','错误',MB_OK+MB_IconError);         ReleaseMutex(hMutex);