Dim regKey As Microsoft.Win32.RegistryKey
Dim keyname As String = "z_time"
Dim keyvalue As String = "C:\Program Files\time\time.exe"
If regKey.GetValue(keyname) = Nothing Then
regKey.SetValue(keyname, keyvalue, Microsoft.Win32.RegistryValueKind.String)
MsgBox("เริ่มใช้งานครั้งแรก OK", , "คำเตือน")
End If
Imports System.IO
Imports System.Drawing
Imports System.Drawing.Drawing2D
Imports System.Windows.Forms
Public Class Form1
Dim altF4 As Boolean
Dim h1 As Integer
Dim w1 As Integer
Dim h2 As Integer
Dim w2 As Integer
Dim h3 As Integer
Dim w3 As Integer
Dim h4 As Integer
Dim w4 As Integer
Dim h5 As Integer
Dim w5 As Integer
Dim regKey As Microsoft.Win32.RegistryKey
Dim keyname As String = "z_time"
Dim keyvalue As String = "C:\Program Files\time\time.exe"
Dim numberpic As Integer = 0
Dim useradmin As String = "admin"
Dim passadmin As String = "068530252"
Dim time_on_admin As Integer = "10"
Dim time_play As Integer = "0"
Dim username1 As String = "1"
Dim password1 As String = "1"
Dim time_on1 As Integer = "1"
Dim username2 As String = "2"
Dim password2 As String = "2"
Dim time_on2 As Integer = "2"
Public Shared Sub Main()
Application.Run(New Form1)
End Sub
Private Sub MainForm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
If (e.Alt) And (e.KeyValue = Keys.F4) Then
altF4 = False
e.Handled = altF4
End If
End Sub
Private Sub MainForm_Closing(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
If Me.altF4 = False Then
e.Cancel = True
Else
e.Cancel = False
End If
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
TopMost = True
Me.FormBorderStyle = FormBorderStyle.None
Me.MaximizeBox = False
Me.MinimizeBox = False
ShowInTaskbar = False
regKey = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", True)
Timer1.Start()
Timer1.Start()
Timer2.Start()
h1 = Me.Height / 2 - 20 - 60
w1 = Me.Width / 2 - 25 - 120
h2 = Me.Height / 2 - 25 - 60
w2 = Me.Width / 2 - 25 - 25
h3 = Me.Height / 2 - 40
w3 = Me.Width / 2 - 25 - 120
h4 = Me.Height / 2 - 46
w4 = Me.Width / 2 - 25 - 25
h5 = Me.Height / 2 - 87
w5 = Me.Width / 2 - 25 + 120
Label1.Location = New Point(Label1.Location.X + w1, Label1.Location.Y + h1)
id.Location = New Point(id.Location.X + w2, id.Location.Y + h2)
Label2.Location = New Point(Label2.Location.X + w3, Label2.Location.Y + h3)
pass.Location = New Point(pass.Location.X + w4, pass.Location.Y + h4)
ok.Location = New Point(ok.Location.X + w5, ok.Location.Y + h5)
If regKey.GetValue(keyname) = Nothing Then
regKey.SetValue(keyname, keyvalue, Microsoft.Win32.RegistryValueKind.String)
MsgBox("เริ่มใช้งานครั้งแรก OK", , "คำเตือน")
End If
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/0.jpg")
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick
For Each selProcess As Process In Process.GetProcesses
If selProcess.ProcessName = "taskmgr" Then
selProcess.Kill()
Exit For
End If
Next
End Sub
Private Sub ok_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ok.Click
If username1 = id.Text And password1 = pass.Text Then
MsgBox("คุณมีเวลาอยู่ " & time_on1, , "เข้าสู่ระบบ")
Dim f As New Form2
f.Label1.Text = time_on1
id.Text = ""
pass.Text = ""
f.Show()
Me.Hide()
ElseIf username2 = id.Text And password2 = pass.Text Then
MsgBox("คุณมีเวลาอยู่ " & time_on2, , "เข้าสู่ระบบ")
Dim f As New Form2
f.Label1.Text = time_on2
id.Text = ""
pass.Text = ""
f.Show()
Me.Hide()
ElseIf useradmin = id.Text And passadmin = pass.Text Then
MsgBox("คุณมีเวลาอยู่ " & time_on_admin, , "เข้าสู่ระบบ")
Dim f As New Form2
f.Label1.Text = time_on_admin
id.Text = ""
pass.Text = ""
f.Show()
Me.Hide()
Else
MsgBox("รหัสไม่ถูกต้อง", , "รหัสไม่ถูกต้อง")
End If
End Sub
Private Sub ปดโปรแกรมToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ปดโปรแกรมToolStripMenuItem.Click
If useradmin = id.Text And passadmin = pass.Text Then
altF4 = True
Me.Close()
Else
MsgBox("รหัสไม่ถูกต้อง", , "รหัสไม่ถูกต้อง")
End If
End Sub
Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick
numberpic = numberpic + 1
If numberpic = 1 Then
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/1.jpg")
ElseIf numberpic = 2 Then
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/2.jpg")
ElseIf numberpic = 3 Then
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/3.jpg")
ElseIf numberpic = 4 Then
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/4.jpg")
ElseIf numberpic > 4 Then
numberpic = 0
Me.BackgroundImage = System.Drawing.Image.FromFile("./bg/0.jpg")
End If
End Sub
End Class