Gracias David, ahora el resultado es al contrario, para cualquier boton que ejecuto me dice que la ventana no esta abierta, y
ret para cualquier boton siempre me esta dando cero.
Este es el codigo:
Código PHP:
Public Class Form1
Const MSOutlook = "OpusApp"
Const MSExcel = "XLMAIN"
Const MSIExplorer = "IEFrame"
Const MSVBasic = "wndclass_desked_gsk"
Const NotePad = "Notepad.txt"
Const MyVBApp = "ThunderForm"
<System.Runtime.InteropServices.DllImport("user32.dll")> _
Private Shared Function FindWindow( _
ByVal lpClassName As String, _
ByVal lpWindowName As String) As System.IntPtr
End Function
Private Sub Comprobar(ByVal clase As String)
Dim ret As Long
ret = FindWindow("Clase", Nothing)
If ret <> 0 Then
MsgBox("La aplicación está abierta", vbInformation + vbOKOnly)
Else
MsgBox("La aplicación NO está abierta", vbInformation + vbOKOnly)
End If
End Sub
Private Sub Form_Load()
Button1.Capture = " Internet Explorer "
Button2.Capture = " Microsoft Outlook "
Button3.Capture = " Microsoft Excel "
Button4.Capture = " Bloc de notas "
Button5.Capture = " Visual basic "
End Sub
Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Comprobar(NotePad)
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Comprobar(MSIExplorer)
End Sub
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Comprobar(MSExcel)
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Comprobar(MSOutlook)
End Sub
Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click
Comprobar(MSVBasic)
End Sub
End Class
Aqui el cambio que hice fue
.caption por
.capture, donde se esta cargando el form, ya que si dejo caption, el programa me da un error de que Caption no es miembro de
Systems.Windows.Forms.Button