If App.PrevInstance = True Then
MsgBox "本程序已经运行,不能多次运行!", vbExclamation, "警告"
End
End If
MsgBox "本程序已经运行,不能多次运行!", vbExclamation, "警告"
End
End If
解决方案 »
- 怎样提取DATAGRID中游标指示一行中的数据
- 求ACCESS数据库备份问题,在线等,急
- 请问如何在VC中调用VB编写的ActiveX.exe,急~~~
- 谁做过考试系统?数据库该怎么建?
- 怎么样查找一维数组中的最大值?
- 怎么样用VB程序获得CPU的序列号或主板的序列号??在线等待,马上结分!
- VB下载网页代码的问题
- 如何将数据库里的数据与textbox绑定?
- 谁这么讨厌把我的鼠标右键封了?用短消息干的吗?
- 各位大哥帮帮忙,一定送分!谢绝胡说八道,无稽之谈,我心情不好
- 请问在VB中用ADO查询数据库的日期问题
- 系统NT4.0,VB6中加入TEXT、CHECK BOX,都会出现该内存不能为READ
Public Const GW_CHILD As Long = 5&
Public Const GW_HWNDNEXT As Long = 2&
Public Declare Function GetDesktopWindow& Lib "user32" ()
Public Declare Function GetWindow& Lib "user32" (ByVal hwnd&, ByVal wCmd&)
Public Declare Function GetWindowText& Lib "user32" Alias "GetWindowTextA" _
(ByVal hwnd&, ByVal lpString$, ByVal cch&)
Public Declare Function ShowWindow& Lib "user32" (ByVal hwnd&, ByVal nCmdShow&)
Public Declare Function GetWindowRect& Lib "user32" (ByVal hwnd&, lpRect As RECT)
Public Declare Function MoveWindow& Lib "user32" (ByVal hwnd&, ByVal X&, _
ByVal Y&, ByVal nWidth&, ByVal nHeight&, ByVal bRepaint&)
Public Declare Function SetForegroundWindow& Lib "user32" (ByVal hwnd&)
Public Declare Function FindWindow& Lib "user32" Alias "FindWindowA" _
(ByVal lpClassName$, ByVal lpWindowName$)
Const sBaseCaption As String = "登录窗口"
Const sBaseCaption1 As String = "FileManager"
'以上换成您的application的title
If App.PrevInstance = True Then
Dim hAppWindow&, sTemp$
hAppWindow = GetWindow(GetDesktopWindow(), GW_CHILD)
Do
sTemp = String$(180, False)
Call GetWindowText(hAppWindow, sTemp, 179)
If InStr(sTemp, sBaseCaption) Then
ActivatePrevInstance (hAppWindow) '使以前的窗口活动
Exit Do
End If
If InStr(sTemp, sBaseCaption1) Then
ActivatePrevInstance (hAppWindow) '使以前的窗口活动
Exit Do
End If
' 获得下一个子窗体
hAppWindow = GetWindow(hAppWindow, GW_HWNDNEXT)
Loop
Else '第一次运行时
frmLogin.Show
End IfPrivate Sub ActivatePrevInstance(ByVal hAppWindow&) Call ShowWindow(hAppWindow, SW_RESTORE) '使窗口活动
Call SetForegroundWindow(hAppWindow)
End Sub
I have added score for you.have you received 20 points?
If App.PrevInstance = True Then
name0 = App.EXEName
res = MsgBox("该程序已运行,不能再次装载!", vbExclamation, name0)
If res = vbYes Then
Unload Me
End If
End If