永发信息网

一句话问题:如何防止VB程序被强行关闭?

答案:2  悬赏:40  手机版
解决时间 2021-01-25 06:15
  • 提问者网友:感性作祟
  • 2021-01-25 00:52
我要代码和那个原理介绍 谢谢
最佳答案
  • 五星知识达人网友:纵马山川剑自提
  • 2021-01-25 01:47
Function CheckApplicationIsRun(ByVal szExeFileName As String) As Boolean
On Error GoTo Err
Dim WMI
Dim Obj
Dim Objs
CheckApplicationIsRun = False
Set WMI = GetObject("WinMgmts:")
Set Objs = WMI.InstancesOf("Win32_Process")
For Each Obj In Objs
If InStr(UCase(szExeFileName), UCase(Obj.Description)) <> 0 Then
CheckApplicationIsRun = True
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
End If
Next
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
Exit Function
Err:
If Not Objs Is Nothing Then Set Objs = Nothing
If Not WMI Is Nothing Then Set WMI = Nothing
End Function Private Sub Form_Load()
If CheckApplicationIsRun("abc.exe") = True Then
Else
Shell "C:\abc.exe" End If双进程互保,不懂追问
End Sub
全部回答
  • 1楼网友:未来江山和你
  • 2021-01-25 02:08
msgbox "i love this game!"
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯