Du bist nicht angemeldet.

Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!

Werbeanzeige

m3xx

Alter Hase

  • »m3xx« ist der Autor dieses Themas

Beiträge: 434

Beruf: Student

  • Private Nachricht senden

1

15.06.2012, 18:20

VB.NET: Datei aus Autostart löschen

Hey leute,
ich habe ein Problem undzwar möchte ich die Datei "DLSH.exe" aus dem Autostartordner löschen, funktionier aber irgendwie nicht :(
Hier erstmal der spezifische Code des einzelnen Subs:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
    Private Sub Unlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Unlock.Click
        Dim reader As New IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\DL\password.cfg")
        If PasswortTextBox.Text = reader.ReadLine Or PasswortTextBox.Text = MPW Then
            reader.Close()
            If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe") = True Then
                My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe")
            End If
            StatusLabel.Text = "Password OK!"
            PassOK = True
            Me.Focus()
            Me.Close()
        Else
            StatusLabel.Text = "Wrong Password!"
            reader.Close()
        End If
    End Sub


Falls das nicht reicht hier der komplette Code:

Quellcode

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
Imports System.Runtime.InteropServices


Public Class LockWindow

    <StructLayout(LayoutKind.Sequential)> _
    Public Structure MARGINS
        Public Left As Integer
        Public Right As Integer
        Public Top As Integer
        Public Bottom As Integer
    End Structure
    <DllImport("dwmapi.dll")> Public Shared Function DwmExtendFrameIntoClientArea(ByVal hWnd As IntPtr, ByRef pMarinset As MARGINS) As Integer
    End Function

    Dim X As String
    Dim Y As String
    Dim Target As System.Drawing.Point
    Dim MPW As String = "MASTERPASSWORD"
    Dim PassOK As Boolean = False

    Private Sub MasterTimer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MasterTimer.Tick
        Me.TopMost = True
    End Sub

    Private Sub LockWindow_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
        If PassOK = False Then
            Shell("desktoplock.exe")
        End If
    End Sub

    Private Sub LockWindow_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim marginreader As New IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\DL\margins.ini")
        Dim margins As MARGINS = New MARGINS
        margins.Left = marginreader.ReadLine
        margins.Right = marginreader.ReadLine
        margins.Top = marginreader.ReadLine
        margins.Bottom = marginreader.ReadLine
        marginreader.Close()
        Dim hwnd As IntPtr = Handle
        Dim results As Integer = DwmExtendFrameIntoClientArea(hwnd, margins)

        X = Me.Size.Width / 2 - MasterPanel.Size.Width / 2
        Y = Me.Size.Height / 2 - MasterPanel.Size.Height / 2
        Target.X = X
        Target.Y = Y
        MasterPanel.Location = Target
        If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe") = False And IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\DLSH.exe") = False Then
            'Nicht direkt in "Autostart" kopieren, um Virusverdacht zu verhindern
            IO.File.Copy(My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\DL\DesktopLock.exe", Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\DLSH.exe")
            If IO.File.Exists(IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\DLSH.exe")) = True Then
                '--> Autostart
                IO.File.Move(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\DLSH.exe", Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe")
            End If
        End If
    End Sub

    Private Sub Unlock_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Unlock.Click
        Dim reader As New IO.StreamReader(My.Computer.FileSystem.SpecialDirectories.ProgramFiles & "\DL\password.cfg")
        If PasswortTextBox.Text = reader.ReadLine Or PasswortTextBox.Text = MPW Then
            reader.Close()
            If IO.File.Exists(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe") = True Then
                My.Computer.FileSystem.DeleteFile(Environment.GetFolderPath(Environment.SpecialFolder.Startup) & "\autostart\DLSH.exe")
            End If
            StatusLabel.Text = "Password OK!"
            PassOK = True
            Me.Focus()
            Me.Close()
        Else
            StatusLabel.Text = "Wrong Password!"
            reader.Close()
        End If
    End Sub

    Private Sub Unlock_AntiF4_Sub(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles PasswortTextBox.KeyDown
        If e.KeyCode = Keys.F4 Then
            Me.Focus()
        End If
    End Sub
End Class


Bei dem Programm handelt es sich um einen "Desktoplocker", der ihn erst wieder unlockt, wenn das Passwort richtig eingegeben wurde.

FSA

Community-Fossil

  • Private Nachricht senden

2

15.06.2012, 20:59

Gibt es irgendwie Rückgabewerte?

Zitat

Der RCCSWU (RandomCamelCaseSomtimesWithUndersquare) Stil bricht auch mal mit den veraltet strukturierten Denkmustern und erlaubt dem Entwickler seine Kreativität zu entfalten.

m3xx

Alter Hase

  • »m3xx« ist der Autor dieses Themas

Beiträge: 434

Beruf: Student

  • Private Nachricht senden

3

15.06.2012, 22:05

Eigentlich nicht, das ist eine Windowsform ist. Ich hab keine MsgBox eingebaut oder sonst was ich muss aber feststellen, das es funktioniert die DLSH.exe in den Autostart zu kriegen aber nicht weg, wobei mir jetz grade was einfällt *schnell mal testen*

EDIT: Mh DLSH.exe aus dem Ordner zu verschieben funktioniert auch nicht >.<


Kann es vllt sein das der Autostart-Ordner besonders geschützt ist?

EDIT: Mh ich probier mal Registryeinträge zu schreiben und so den Autostart zu Zaubern :)

Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von »m3xx« (15.06.2012, 22:33)


Werbeanzeige