怎样阻止程序被重复打开,就是确定只让一个程序在运行者?
解决方案 »
- 用commdlg打开无后缀名的文件显示Run-time error `75`:path/file access error
- 关于图片文件的操作问题,谢谢
- 那位高手指点,怎么实现将浮点数转为十六进制(4位)的?
- 我刚数据库中插入一条记录,紧接着再去查询却查不到?什么原因
- 急!!!推荐能够实现子控件排序和拖动的容器控件
- 小小一个查询问题!SOS!!!
- 关于For Each...Next语句的问题
- 串口com1紧急求救????字库方面的问题???
- 我的SQL SEVER服务启动不了 信息是SQL SERVER 不存在OR 访问被拒绝CONNECTIONSOPEN[CONNECT] 请指教
- 不停接收数据~取5个获得均值~怎么让后来的数据不重新刷新掉平均值??
- vb创建odbc数据源的问题
- 请问高手怎样用VB编写一个简单的FLASH播放器(解决立马给分)??????
If App.PrevInstance Then
MsgBox "该程序已经运行!", vbInformation
end
End If
end sub
MsgBox "本程序已经运行了", vbExclamation Or vbOKOnly, "警告"
End
End If
MsgBox "此程式已在執行中...!", vbExclamation, App.ProductName
End
End If
MsgBox "本程序运行中,请确认重试", VBOKOnly, "出错"
End
End If
MsgBox "本程序已经运行了", vbExclamation Or vbOKOnly, "警告"
End
End If
如果同一 exe 有两个文件(在不同的目录下)同时运行,上面的代码阻止不了。
到最后还是要用到 api 的 findwindow 。如果要求不特殊,App.PrevInstance = True 也够了。
Form_Load()
If App.PrevInstance Then End
End Sub另外 fxy_2002(阿勇) :"如果同一 exe 有两个文件(在不同的目录下)同时运行,上面的代码阻止不了"好象没有这种事发生.我试验的结果是照样不会运行第2个实例(除非你改了工程的名字)
App.PrevInstance Then End
你现在在试试,呵呵
大家顶得太快了
MsgBox "程序已经运行!", VBOKOnly, "警告"
End
End If
If App.PrevInstance Then
MsgBox "该程序已经运行!", vbInformation
end
End If
end sub
或者
sub main()
If App.PrevInstance Then
MsgBox "该程序已经运行!", vbInformation
end
End If
end sub
private sub form_load()
If App.PrevInstance Then
MsgBox "该程序已经运行!", vbInformation
end
End If
end sub
If App.PrevInstance Then
MsgBox "该程序已经运行!", vbInformation
end
End If
而是
If App.PrevInstance Then
‘把之前已经打开的程序提到最前面来。不知怎么实现。难道要用findwindow吗?
end
End If
建议多看看win32编程。