Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Long
Private Sub Form_Load()
Me.Caption = "APPa"
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
If FindWindow(vbNullString, "APPb") = 0 Then Shell "APPb.exe", vbNormalFocus
End Sub
'用以上代码生成“APPa.exe”
'=========================================================================
'用以下代码生成“APPb.exe”
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal
lpWindowName As String) As Long
Private Sub Form_Load()
Me.Caption = "APPb"
Timer1.Interval = 1
End Sub
Private Sub Timer1_Timer()
If FindWindow(vbNullString, "APPa") = 0 Then Shell "APPa.exe", vbNormalFocus
End Sub
'两个exe放在同一路径下,从此“APPa”和“APPb”一起过着幸福快乐的日子^_^
以上使用了timer.
下一个没有使用timer
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
Dim Doloop As Boolean
Me.Caption = "APPa"
Do
DoEvents
If FindWindow(vbNullString, "APPb") = 0 Then Shell "APPb.exe", vbNormalFocus
Loop Until Doloop = True
End Sub
'用以上代码生成“APPa.exe”
'=========================================================================
'用以下代码生成“APPb.exe”
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Sub Form_Load()
Dim Doloop As Boolean
Me.Caption = "APPb"
Do
DoEvents
If FindWindow(vbNullString, "APPa") = 0 Then Shell "APPa.exe", vbNormalFocus
Loop Until Doloop = True
End Sub
'无敌版.....