VB怎样判断、防止程序重复执行
Private Sub Form_load()
'判断程序是否已经运行
If App.PrevInstance
Then
MsgBox "本程序已经运行!", vbInformation Or vbOKOnly, "提示信息"
Unload
Me
Exit Sub
End If
'以下是主要程序
' ……
End
Sub
附:另一个例子:
Option Explicit
Public Sub CheckExist(fm
As Form) '防止程序重复执行
Dim title As String
If App.PrevInstance
Then
title = App.title
Call MsgBox("这程序已执行",
vbCritical)
App.title = "" '如此才不会 Avtivate 到自己
fm.Caption =
""
AppActivate title 'activate 先前就已运行的程序
End ' 结束
End
If
End Sub
Private Sub Form_Load()
Call
CheckExist(Me)
End Sub
相关文档:
'代码:
Option Explicit
'======================用于查找进程和终止进程的API函数常数定义================ =====
Private Declare Function CreateToolhelpSnapshot Lib "kernel32" Alias "CreateToolhelp32Snapshot" (ByVal lFlags As Long, ByVal lProcessID As Long) As Long
Private Declare Function ProcessF ......
键盘是我们使用计算机的一个很重要的输入设备了,即使在鼠标大行其道的今天,很多程序依然离不开键盘来操作。但是有时候,一些重复性的,很繁琐的键盘操作 总会让人疲惫,于是就有了用程序来代替人们按键的方法,这样可以把很多重复性的键盘操作交给程序来模拟,省了很多精力,按键精灵就是这样的一个软件。那么 我们怎样才 ......
Private Declare Function URLDownloadToFile Lib "urlmon" Alias "URLDownloadToFileA" (ByVal pCaller As Long, ByVal szURL As String, ByVal szFileName As String, ByVal dwReserved As Long, ByVal lpfnCB As Long) As Long
Private Sub Command1_Click()
Dim Url As String, Filepath As String
Url = "h ......
VERSION 5.00
Begin VB.Form Form2
AutoRedraw = -1 'True
Caption = "计算界面"
ClientHeight = 4905
ClientLe ......
Option Explicit
Dim potflag As Integer '标识是否用小数点
Dim numcol As Integer ' 点击运算符的个数
Dim LastInput ' 指示上一次操作的内容
Dim colflag ......