比如有程序main.exe,如果限制只能运行一个实例,就是不允许打开几个同时运行的那种!
解决方案 »
- tclientdataset 与 tdatasetprovider简单运用??
- Delphi技术交流群-16818992-欢迎大家加入-顶者有分
- 谁能给我一些delphi编写的病毒的例子啊,谢谢啦
- 各位推荐一下好的DELPHI站点好吗?
- 如何在DELPHI 程序中创建数据库 和修改表名? 急用 HELPING!!!!!!!!!!!
- 如何设置Tchart的背景网格的宽度??
- 一个很急的问题: 我的数据库所有汉字的部分显示的全都是"?????".在线等待
- 只要query.active=true一调出某工程文件程序delphi6就自动退出
- 如何控制 ValueListEditor ?有一个Help这样写道:
- 数据库别名配置
- IDHTTP 和 ICS HTTP 的 SSL 问题
- 关于IMediaSample2的SetMediaType的问题
if GetLastError = ERROR_ALREADY_EXISTS then
begin
MessageBox(Application.Handle,'已经在运行!','提示信息',MB_OK+MB_ICONINFORMATION);
end加到工程文件里
Mutex: THandle;
begin
Mutex := CreateMutex(nil, true, 'Test');
if GetLastError <> ERROR_ALREADY_EXISTS then
begin
Application.Initialize;
Application.CreateForm(TfmMain, fmMain);
Application.Run;
end
else
MessageBox(0, '系统已经正在运行!', '请注意......', 48);
ReleaseMutex(Mutex);
end.
project Test;uses
Windows,
Forms,
mainUnit in 'mainUnit.pas' {FormMain};{$R *.res}var
appAtom : THandle;
begin Application.Initialize; if 0 = GlobalFindAtom('SOME-UNIQUE-TEXT-RELATED-TO-THIS-APPLICATION') then
begin
appAtom := GlobalAddAtom('SOME-UNIQUE-TEXT-RELATED-TO-THIS-APPLICATION') ; try
Application.CreateForm(TFormMain, FormMain) ;
Application.Run;
finally
GlobalDeleteAtom(appAtom);
end
end
else
begin
Application.MessageBox('程序已运行!') ;
end;