怎么在关闭vb一生成的工程 时 同时关闭了他的连接程序!??

来源:百度知道 编辑:UC知道 时间:2024/06/17 10:15:29
如果一个vb 已生成的工程 打开时 ,会连接到一个其他的软件 或程序。如果关闭时 本工程会关闭 。但是他连接的 程序或软件无法关闭 。 如果想让它链接得 程序随着 关闭工程 而关闭 其代码 怎么写啊 !希望高手 帮助一下啊!!??

以系统自带的纸牌为例子吧!

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function GetForegroundWindow Lib "user32" () As Long
Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long

Private Sub Form_Load()
Timer1.Interval = 100
Shell "C:\WINDOWS\system32\sol.exe"
End Sub

Private Sub Timer1_Timer()
Dim hwnd As Long
hwnd = FindWindow(vbNullString, "纸牌")
If hwnd = 0 Then
End
End If
End Sub

Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long

Private Declare Function SendMessage Lib "user32" Alias "Send