21 Mart 2014 Cuma
EKRANI KİLİTLEME PROJE ÖRNEĞİ
Oto Ekspertiz Cihazları hakkında bilgi almak isterseniz
burayı
tıklayın
18.10.2015
Tarihinde Güncellendi
EKRANI KİLİTLEME PROJE ÖRNEĞİ
İNDİR
EKRANI KİLİTLE (Sadece EXE)
İNDİR
AnaFrm
Public Class AnaFrm Dim Parola As String = "" Dim UygulamaAdi As String = ""
_ Public Shared Function ShowWindowAsync(ByVal hWnd As IntPtr, ByVal swCommand As Integer) As Integer End Function Public Sub AnaFrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Height = 183 KalkanRengi = GetSetting(Application.ProductName, ProductName, "Kalkan Rengi", 1) Select Case KalkanRengi Case 1 KalkanFrm.BackColor = Color.SteelBlue RadioButton1.Checked = True Case 2 KalkanFrm.BackColor = Color.Yellow RadioButton2.Checked = True Case 3 KalkanFrm.BackColor = Color.Red RadioButton3.Checked = True Case 4 KalkanFrm.BackColor = Color.Green RadioButton4.Checked = True End Select SesCmb.Items.Add("Hiçbiri") SesCmb.Items.Add("Ses1") SesCmb.Items.Add("Ses2") SesCmb.Items.Add("Ses3") SesCmb.SelectedIndex = 1 KlavyeyiBagla() End Sub Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ParolaTxt.TextChanged If ParolaTxt.Text = Parola Then Me.KapatBtn.Text = "KAPAT" Panel2.Enabled = True EtkinlestirBtn.Enabled = True AcceptButton = KapatBtn KapatBtn.Enabled = True Else Panel1.Enabled = True End If End Sub Private Sub EtkinlestirBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles EtkinlestirBtn.Click If Not ParolaTxt.Text <> "" Then 'şifre girilmemişse My.Computer.Audio.Play(Application.StartupPath & "\ses\s02.wav", AudioPlayMode.WaitToComplete) : Exit Sub End If If SesCmb.SelectedIndex > 0 Then My.Computer.Audio.Play(Application.StartupPath & "\ses\s01.wav", AudioPlayMode.Background) EtkinlestirBtn.Visible = False End If Parola = ParolaTxt.Text ParolaTxt.Text = "" Me.Hide() Dim f As New KalkanFrm f.Show() ParolaTxt.PasswordChar = "*" EtkinlestirBtn.Enabled = False End Sub Private Sub KapatBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles KapatBtn.Click If Parola <> ParolaTxt.Text Then Me.Hide() : Exit Sub 'parola girilmezse çık UnhookKeyboard() If SesCmb.SelectedIndex > 0 Then My.Computer.Audio.Play(Application.StartupPath & "\ses\s02.wav", AudioPlayMode.WaitToComplete) Dim f As New KalkanFrm f.Hide() End If Me.Close() End Sub Private Sub AçBtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AçBtn.Click Call DosyaCalistir() If Parola <> ParolaTxt.Text Then Me.Hide() End Sub Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GözatBtn.Click 'OpenFileDialog1.ShowDialog() OpenFileDialog1.Title = " Ekran Kilitliyken açmak istediğiniz bir Dosyayı Seçiniz" OpenFileDialog1.Filter = "EXE Dosyalar|*.exe|Tüm Dosyalar|*.*" OpenFileDialog1.FilterIndex = 1 OpenFileDialog1.FileName = "C:\Program Files (x86)\Windows Media Player\wmplayer.exe" If OpenFileDialog1.ShowDialog() = DialogResult.OK Then AçBtn.Enabled = True DsyYoluTxt.Text = OpenFileDialog1.FileName Else 'MessageBox.Show("Dosya seçmediniz") AçBtn.Enabled = False End If End Sub Public Sub DosyaCalistir() Dim Engelle As Process For Each Engelle In Process.GetProcesses If Engelle.ProcessName = UygulamaAdi Then Dim SureciBaslat As Process() = Process.GetProcessesByName(UygulamaAdi) ShowWindowAsync(SureciBaslat(0).MainWindowHandle, 2) 'Minimize ShowWindowAsync(SureciBaslat(0).MainWindowHandle, 9) 'Restore Exit Sub End If Next Engelle Try System.Diagnostics.Process.Start(DsyYoluTxt.Text) SurecAdiSakla() Catch ex As Exception MsgBox("Ekran Kilitli iken çalıştırılacak" & vbCrLf & " olan dosya yolu belirtilmemiş." & vbCrLf & "GÖZAT kısmından dosya seçiniz") Me.Show() End Try End Sub Private Sub SurecAdiSakla() Console.WriteLine("***SurecAdiSakla") Dim x As Byte Dim Gecici As String = "" Dim SurecYolu As String = DsyYoluTxt.Text For x = 0 To SurecYolu.Length - 1 UygulamaAdi += SurecYolu.Chars(x) If SurecYolu.Chars(x) = "\" Then UygulamaAdi = "" End If Console.WriteLine(UygulamaAdi) Next For x = 0 To UygulamaAdi.Length - 1 If UygulamaAdi.Chars(x) = "." Then Exit For Gecici += UygulamaAdi.Chars(x) Next UygulamaAdi = Gecici Console.WriteLine(UygulamaAdi) End Sub Private Sub TextBox2_TextChanged(sender As System.Object, e As System.EventArgs) Handles DsyYoluTxt.TextChanged AçBtn.Enabled = True End Sub Private Sub YardımBtn_Click(sender As System.Object, e As System.EventArgs) Handles YardımBtn.Click '326; 382 If Me.Height = 183 Then Me.Height = 420 Else Me.Height = 183 End If End Sub Private Sub Button1_MouseHover(sender As System.Object, e As System.EventArgs) Handles EtkinlestirBtn.MouseHover Dim tooltip As New ToolTip() tooltip.SetToolTip(EtkinlestirBtn, "Önce Şifre girişi Yapınız") End Sub Private Sub Button4_MouseLeave(sender As System.Object, e As System.EventArgs) Handles GözatBtn.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(GözatBtn, "Çalışmasını istediğiniz bir program yolu Giriniz" & _ vbCrLf & "Kalkan aktifken F11 Tuşu ile Dosyayı çalıştırabilirsiniz.") End Sub Private Sub ComboBox1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles SesCmb.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(SesCmb, "Uyarı için bir ses seçiniz.") End Sub Private Sub Button5_MouseLeave(sender As System.Object, e As System.EventArgs) Handles YardımBtn.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(YardımBtn, "Yardım için Tıklayın") End Sub Private Sub Button3_MouseLeave(sender As System.Object, e As System.EventArgs) Handles AçBtn.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(AçBtn, "Yolunu belirlediğiniz dosyayı çalıştırın") End Sub Private Sub RadioButton1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton1.CheckedChanged KalkanRengi = 1 KalkanFrm.BackColor = Color.SteelBlue SaveSetting(Application.ProductName, ProductName, "Kalkan Rengi", KalkanRengi) End Sub Private Sub RadioButton3_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton3.CheckedChanged KalkanRengi = 2 KalkanFrm.BackColor = Color.Yellow SaveSetting(Application.ProductName, ProductName, "Kalkan Rengi", KalkanRengi) End Sub Private Sub RadioButton2_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton2.CheckedChanged KalkanRengi = 3 KalkanFrm.BackColor = Color.Red SaveSetting(Application.ProductName, ProductName, "Kalkan Rengi", KalkanRengi) End Sub Private Sub RadioButton4_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles RadioButton4.CheckedChanged KalkanRengi = 4 KalkanFrm.BackColor = Color.Green SaveSetting(Application.ProductName, ProductName, "Kalkan Rengi", KalkanRengi) End Sub Private Sub ParolaTxt_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles ParolaTxt.KeyDown If e.KeyCode = Keys.Escape Then Me.Hide() End If End Sub End Class
KalkanFrm
Public Class KalkanFrm Private Sub KalkanFrm_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Width = Screen.PrimaryScreen.Bounds.Width Me.Height = Screen.PrimaryScreen.Bounds.Height KalkanRengi = GetSetting(Application.ProductName, ProductName, "Kalkan Rengi", 1) Select Case KalkanRengi Case 1 Me.BackColor = Color.SteelBlue Case 2 Me.BackColor = Color.Yellow Case 3 Me.BackColor = Color.Red Case 4 Me.BackColor = Color.Green End Select End Sub Private Sub KalkanFrm_MouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseClick On Error Resume Next Select Case AnaFrm.SesCmb.SelectedIndex Case 0 My.Computer.Audio.Play(Application.StartupPath & "\ses\Klik1.wav", AudioPlayMode.Background) Case 1 My.Computer.Audio.Play(Application.StartupPath & "\ses\Klik1.wav", AudioPlayMode.Background) Case 2 My.Computer.Audio.Play(Application.StartupPath & "\ses\Klik2.wav", AudioPlayMode.Background) Case 3 My.Computer.Audio.Play(Application.StartupPath & "\ses\Klik3.wav", AudioPlayMode.Background) End Select End Sub Private Sub KalkanFrm_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown If e.KeyCode = Keys.F12 Then AcceptButton = AnaFrm.KapatBtn AnaFrm.KapatBtn.Text = "Gizle" AnaFrm.Show() AnaFrm.ParolaTxt.Focus() End If If e.KeyCode = Keys.F11 Then AnaFrm.DosyaCalistir() End If End Sub Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick 'Taskmanager ile kapatılmak istenirse Engelle Try Dim Engelle As Process For Each Engelle In Process.GetProcesses If Engelle.ProcessName = "taskmgr" Then Engelle.Kill() End If Next Engelle Catch ex As Exception MessageBox.Show(ex.Message) End Try End Sub Private Sub KalkanFrm_Resize(sender As Object, e As System.EventArgs) Handles Me.Resize KilitPic.Top = 275 KilitPic.Left = 600 End Sub End Class
KlavyeModul
Imports System.Runtime.InteropServices Imports System.Reflection Imports System.Drawing Imports System.Threading Module Klavye Public KalkanRengi As Integer Public Structure KBDLLHOOKSTRUCT Public vkCode As Integer Public scanCode As Integer Public flags As Integer Public time As Integer Public dwExtraInfo As Integer End Structure Public Declare Function UnhookWindowsHookEx Lib "user32" _ (ByVal hHook As Integer) As Integer Public Declare Function SetWindowsHookEx Lib "user32" _ Alias "SetWindowsHookExA" (ByVal idHook As Integer, _ ByVal lpfn As KeyboardHookDelegate, ByVal hmod As Integer, _ ByVal dwThreadId As Integer) As Integer Private Declare Function GetAsyncKeyState Lib "user32" _ (ByVal vKey As Integer) As Integer Private Declare Function CallNextHookEx Lib "user32" _ (ByVal hHook As Integer, ByVal nCode As Integer, _ ByVal wParam As Integer, ByVal lParam As KBDLLHOOKSTRUCT) As Integer Private Const HC_ACTION As Integer = 0 Private Const WH_KEYBOARD_LL As Integer = 13& Public KlavyeHND As Integer Public Function BagliMi(ByRef Hookstruct As KBDLLHOOKSTRUCT) As Boolean Select Case Hookstruct.vkCode Case 41 To &H5A Return False 'A-Z harfler Case 8 Return False 'geri tuşu Case 14 Return False 'Capslock tuşu Case &HD Return False 'Enter tuşu Case 20 Return False 'Boşlık tuşu çalışmaz Case 25, 26, 27, 28 Return False 'Tüm 4 Ok tuşları, ESC Case 2D Return False 'INS tuşu Case &H6E Return False Case &H7A Return False 'F11 Case &H7B Return False 'F12 End Select Return True End Function Public Function KlavyeGeriAl(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer If (Code = HC_ACTION) And (BagliMi(lParam)) Then Return 1 End If Return CallNextHookEx(KlavyeHND, Code, wParam, lParam) End Function Public Delegate Function KeyboardHookDelegate(ByVal Code As Integer, ByVal wParam As Integer, ByRef lParam As KBDLLHOOKSTRUCT) As Integer
Private callback As KeyboardHookDelegate Public Sub KlavyeyiBagla() callback = New KeyboardHookDelegate(AddressOf KlavyeGeriAl) KlavyeHND = SetWindowsHookEx(WH_KEYBOARD_LL, callback, _ Marshal.GetHINSTANCE([Assembly].GetExecutingAssembly.GetModules()(0)).ToInt32, 0) End Sub Private Function Hooked() Hooked = KlavyeHND <> 0 End Function Public Sub UnhookKeyboard() If (Hooked()) Then Call UnhookWindowsHookEx(KlavyeHND) End If End Sub End Module
Sonraki Kayıt
Önceki Kayıt
Ana Sayfa