读书人

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

发布时间: 2012-03-02 14:40:28 作者: rapoo

限制.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); 

读书人网 >.NET

热点推荐