a 程序死掉后,自动重启a程序~有没有具体代码实现?

解决方案 »

  1.   

    我也知道原理是这样有具体的实际代码吗???TO: kmzs(.:RNPA:.山水岿濛)
      

  2.   

    进程1的FORMVERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "进程1"
       ClientHeight    =   3195
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   3  '窗口缺省
       Begin VB.Timer Timer1 
          Interval        =   3000
          Left            =   1320
          Top             =   1320
       End
       Begin VB.CommandButton Command1 
          Caption         =   "Command1"
          Height          =   495
          Left            =   1800
          TabIndex        =   0
          Top             =   1320
          Width           =   1215
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Sub Command1_Click()
    End
    End SubPrivate Sub Timer1_Timer()
    Dim p As String
    If Right(App.Path, 1) = "\" Then
       p = App.Path + "2.exe"
    Else
       p = App.Path + "\2.exe"
    End If
    If FindWindow(vbNullString, "进程2") = 0 Then Shell (p)
    End Sub
      

  3.   

    进程2的FORM
    VERSION 5.00
    Begin VB.Form Form1 
       Caption         =   "进程2"
       ClientHeight    =   3195
       ClientLeft      =   60
       ClientTop       =   345
       ClientWidth     =   4680
       LinkTopic       =   "Form1"
       ScaleHeight     =   3195
       ScaleWidth      =   4680
       StartUpPosition =   3  '窗口缺省
       Begin VB.Timer Timer1 
          Interval        =   3000
          Left            =   1320
          Top             =   1320
       End
       Begin VB.CommandButton Command1 
          Caption         =   "Command1"
          Height          =   495
          Left            =   1800
          TabIndex        =   0
          Top             =   1320
          Width           =   1215
       End
    End
    Attribute VB_Name = "Form1"
    Attribute VB_GlobalNameSpace = False
    Attribute VB_Creatable = False
    Attribute VB_PredeclaredId = True
    Attribute VB_Exposed = False
    Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Sub Command1_Click()
    End
    End SubPrivate Sub Timer1_Timer()
    Dim p As String
    If Right(App.Path, 1) = "\" Then
       p = App.Path + "1.exe"
    Else
       p = App.Path + "\1.exe"
    End If
    If FindWindow(vbNullString, "进程1") = 0 Then Shell (p)
    End Sub
      

  4.   

    可以把TIMER控件的时间改短一点,NT系列是以50毫秒为单位的,98系列的是以200毫秒为单位的