如何实现让一个窗体不能被关闭(VB编程)

如何实现让一个窗体不能被关闭(VB编程),第1张

这个有个笨方法:

private

sub

command2_click()

select

case

text1.text

case

"form1"

form1.show

case

"form2"

form2.show

case

else

mgsbox

"没有这个窗体名"

end

select

end

sub

前提是把所有关的窗体名都要知道

呵呵

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


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/yw/11990012.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-20
下一篇 2023-05-20

发表评论

登录后才能评论

评论列表(0条)

保存