Programm nach Klick auf Bild schließen [Erledigt]

  • VB.NET

Es gibt 10 Antworten in diesem Thema. Der letzte Beitrag () ist von lace.

    Programm nach Klick auf Bild schließen [Erledigt]

    Guten Tag,

    ich hab mal eine Frage. Ich habe ein Bild das verlinkt ist und nun soll sich das Programm, welches das Bild enthält nach 3 Sekunden schließen, wenn man dieses anklickt.

    VB.NET-Quellcode

    1. Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    2. Try
    3. System.IO.File.WriteAllBytes("programm.exe", My.Resources.programm)
    4. System.Diagnostics.Process.Start("programm.exe")
    5. Catch ex As Exception
    6. End Try
    7. End Sub


    Wie lässt sich das realisieren? Ist das überhaupt möglich?

    MfG, skrippi

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „lace“ ()

    VB.NET-Quellcode

    1. Try
    2. System.IO.File.WriteAllBytes("programm.exe", My.Resources.programm)
    3. System.Diagnostics.Process.Start("programm.exe")
    4. Timer1.Interval = 30000
    5. Timer1.Start()
    6. Catch ex As Exception


    und in den Timer1 schreibst du Me.Close()
    den Stellst du auf deine gewünschte Zeit ein.

    VB.NET-Quellcode

    1. Public Class Form1
    2. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    3. Application.Exit()
    4. Timer1.Stop()
    5. End Sub
    6. Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    7. 'Dein Code
    8. 'Programm beenden:
    9. Timer1.Interval = 3000 '3sec
    10. Timer1.Start()
    11. End Sub
    12. End Class


    MFG

    EDIT:


    und in den Timer1 schreibst du Me.Close()
    den Stellst du auf deine gewünschte Zeit ein.

    Me.Close schließt nur die Form! wenn das erwünscht ist das verwänden! ;)
    Ich danke euch vielmals für eure Hilfe. Jedoch funktioniert es nicht, es liegt an mir, ich bin zu dumm^^.

    Also ich poste hier mal meinen ganzen Quellcode hin, ich hab ihn schon 3 mal auf Fehler gecheckt und nichts gefunden. Aber bei Klick auf das Bild passiert nichts. Hängt das vielleicht damit zusammen, das der Klick auf das Bild auch bewirkt, dass dabei eine weitere exe Datei ausgerufen wird???

    VB.NET-Quellcode

    1. Imports Un4seen.Bass
    2. Public Class Form1
    3. Private Declare Function BASS_Init Lib "bass.dll" (ByVal device As Integer, ByVal freq As UInteger, ByVal flags As UInteger, ByVal win As IntPtr, ByVal clsid As UInteger) As Boolean
    4. Private Declare Function BASS_ChannelGetLevel Lib "bass.dll" (ByVal handle As IntPtr) As Integer
    5. Private Declare Function BASS_ChannelPlay Lib "bass.dll" (ByVal handle As IntPtr, ByVal restart As Boolean) As Boolean
    6. Private Declare Function BASS_StreamCreateFile Lib "bass.dll" Alias "BASS_StreamCreateFile" (ByVal mem As Boolean, ByVal file As String, ByVal offset As UInteger, ByVal offsethigh As UInteger, ByVal length As UInteger, ByVal lengthhigh As UInteger, ByVal flags As UInteger) As IntPtr
    7. Dim BASS_STREAM_PRESCAN As UInteger = &H20000
    8. Dim BASS_STREAM_AUTOFREE As UInteger = &H40000
    9. Public stream As IntPtr
    10. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    11. BASS_Init(-1, 44100, 1024, IntPtr.Zero, Nothing)
    12. stream = BASS_StreamCreateFile(False, "techno.mp3", 0, 0, 0, 0, BASS_STREAM_AUTOFREE Or BASS_STREAM_PRESCAN)
    13. BASS_ChannelPlay(stream, True)
    14. End Sub
    15. Private Sub PictureBox1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox1.Click
    16. Try
    17. System.IO.File.WriteAllBytes("programm1.exe", My.Resources.programm1)
    18. System.Diagnostics.Process.Start("programm1.exe")
    19. Catch ex As Exception
    20. Timer1.Interval = 3000 '3sec
    21. Timer1.Start()
    22. End Try
    23. End Sub
    24. Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs)
    25. End Sub
    26. Private Sub Label1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    27. End Sub
    28. Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    29. Application.Exit()
    30. Timer1.Stop()
    31. End Sub
    32. Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles PictureBox5.Click
    33. Try
    34. System.IO.File.WriteAllBytes("programm2.exe", My.Resources.programm2)
    35. System.Diagnostics.Process.Start("programm2.exe")
    36. Catch ex As Exception
    37. End Try
    38. End Sub
    39. End Class

    lace schrieb:

    Private Sub PictureBox5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles

    VB.NET-Quellcode

    1. PictureBox5.Click
    2. Try
    3. System.IO.File.WriteAllBytes("programm2.exe", My.Resources.programm2)
    4. System.Diagnostics.Process.Start("programm2.exe")
    5. ' Zeile 22 und 23 "verschiebst" du hier hin
    6. Timer1.Interval = 3000 '3sec
    7. Timer1.Start()
    8. Catch ex As Exception
    9. End Try
    10. End Sub


    dann sollte es nach dem Cklick auch funktioieren