25 Kasım 2013 Pazartesi
Program Şifremizi Kodlayarak saklamak
Giriş Formu:
Imports Microsoft.Win32 'register için Public Class GirisFrm Dim zx As String Private Sub GirisFrm_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed End End Sub Private Sub GirisFrm_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Try Dim regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", False) Dim subregkey As RegistryKey = regkey.OpenSubKey("unknown", False) sifre = subregkey.GetValue("watchword", Environment.UserDomainName.ToString) If sifre = Environment.UserDomainName.ToString Then Call YeniRegisterKayitAc() subregkey.Close() regkey.Close() UyariLbl.Text = "" ParolaFrm.SifreliKoduCoz() Catch ex As Exception MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Public Sub YeniRegisterKayitAc() For Each t In Environment.UserDomainName.ToString say += 1 If say = 1 Then secenek &= Convert.ToInt32(t) & ":abcçdefgğhıijklmnoöpqrsştuüvwxyz" ElseIf say = 2 Then secenek &= Convert.ToInt32(t) & ":zyxwvüutşsrqpöonmlkjiıhğgfedçcba" ElseIf say = 3 Then secenek &= Convert.ToInt32(t) & ":öonmlkjiıhğgfedçcbazyxwvüutşsrqp" say = 0 End If Next ParolaFrm.YeniSifreTxt1.Text = secenek ParolaFrm.YeniSifreyKaydet() End Sub Private Sub GirisBtn_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles GirisBtn.MouseDown If e.Button = Windows.Forms.MouseButtons.Middle Then SifreTxt.Text = Sifre End If End Sub Private Sub GirisBtn_Click(sender As System.Object, e As System.EventArgs) Handles GirisBtn.Click Timer1.Stop() Select Case SifreTxt.Text Case Is = "" Timer1.Interval = 2000 Timer1.Start() Beep() UyariLbl.Text = "Şifreyi Giriniz" SifreTxt.Focus() Case Is = sifre GirisBtn.Enabled = True MainFrm.Show() Me.Hide() Case Else Timer1.Start() sayac += 1 Timer1.Interval = 2000 Timer1.Start() If sayac = 3 Then UyariLbl.Text = "Yetkili değilsiniz." : GirisBtn.Enabled = False If sayac < 3 Then UyariLbl.Text = "Şifreyi Yanlış Girdiniz" SifreTxt.Text = "" SifreTxt.Focus() End Select End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick UyariLbl.Text = Nothing Timer1.Stop() End Sub Private Sub SifreTxt_MouseLeave(sender As System.Object, e As System.EventArgs) Handles SifreTxt.MouseLeave If Environment.UserDomainName.ToString = sifre Then Dim tooltip As New ToolTip() tooltip.SetToolTip(SifreTxt, "Programın ilk kurulumdaki şifresi" _ & vbCrLf & "(" & Environment.UserDomainName.ToString & ")" _ & vbCrLf & " Bilgisayarınızın Adıdır" _ & vbCrLf & "Harfler Büyükse Aynen girin" _ & vbCrLf & "Sonra Şifrenizi değiştirin") End If End Sub End Class
MainForm :
Public Class MainFrm Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click ParolaFrm.ShowDialog() End Sub End Class
Şifre Değiştirme ve kodlama Formu :
Imports Microsoft.Win32 'register için Public Class ParolaFrm Dim zx As String Private Sub Form2_FormClosed(sender As Object, e As System.Windows.Forms.FormClosedEventArgs) Handles Me.FormClosed GirisFrm.SifreTxt.Text = Nothing GirisFrm.Show() Me.Hide() End Sub Private Sub Form2_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load Call SifreliKoduCoz() GirisFrm.SifreTxt.PasswordChar = Nothing GirisFrm.SifreTxt.PasswordChar = "*" Label4.Text = "" EskiSifreTxt.Text = Nothing Me.EskiSifreTxt.Focus() End Sub Public Sub SifreliKoduCoz() Try Dim regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", False) Dim subregkey As RegistryKey = regkey.OpenSubKey("unknown", False) sifre = subregkey.GetValue("watchword", Environment.UserDomainName.ToString) subregkey.Close() regkey.Close() ButunTxt &= sifre Dim s As String = "abcçdefgğhıijklmnoöpqrsştuüvwxyz" For Each st In s ButunTxt = ButunTxt.Replace(st, "") Next ButunTxt = ButunTxt.Replace(":", vbNewLine) IO.File.WriteAllText("tx.txt", ButunTxt) For Each Me.zx In IO.File.ReadAllLines("tx.txt") y = Convert.ToInt32(zx) u &= Convert.ToChar(y) Next sifre = u ButunTxt = String.Empty u = String.Empty IO.File.Delete("tx.txt") Catch ex As Exception Return 'MsgBox(ex.Message, MsgBoxStyle.Exclamation, Me.Text) End Try End Sub Private Sub CheckBox1_CheckedChanged(sender As System.Object, e As System.EventArgs) Handles CheckBox1.CheckedChanged If CheckBox1.Checked = True Then EskiSifreTxt.UseSystemPasswordChar = False EskiSifreTxt.PasswordChar = "" YeniSifreTxt1.UseSystemPasswordChar = False YeniSifreTxt1.PasswordChar = "" YeniSifreTxt2.UseSystemPasswordChar = False YeniSifreTxt2.PasswordChar = "" If EskiSifreTxt.Text = sifre Then ParolaKaydetBtn.Enabled = True Else ParolaKaydetBtn.Enabled = False End If Else EskiSifreTxt.UseSystemPasswordChar = True EskiSifreTxt.PasswordChar = "*" YeniSifreTxt1.UseSystemPasswordChar = True YeniSifreTxt1.PasswordChar = "*" YeniSifreTxt2.UseSystemPasswordChar = True YeniSifreTxt2.PasswordChar = "*" YeniSifreTxt1.Text = Nothing YeniSifreTxt2.Text = Nothing ParolaKaydetBtn.Enabled = False End If End Sub Private Sub ParolaKaydetBtn_Click(sender As System.Object, e As System.EventArgs) Handles ParolaKaydetBtn.Click If Not YeniSifreTxt1.Text = YeniSifreTxt2.Text Then MessageBox.Show("Şifre ve Tekrarı uyuşmadı") Label2.Visible = False YeniSifreTxt1.Text = Nothing YeniSifreTxt2.Text = Nothing ParolaKaydetBtn.Enabled = False Else Label2.Visible = True YeniSifreTxt1.Visible = True YeniSifreTxt2.Visible = True ParolaKaydetBtn.Enabled = True TextSonu.Text = YeniSifreTxt1.Text Application.DoEvents() For Each t In TextSonu.Text say += 1 If say = 1 Then secenek &= Convert.ToInt32(t) & ":abcçdefgğhıijklmnoöpqrsştuüvwxyz" ElseIf say = 2 Then secenek &= Convert.ToInt32(t) & ":zyxwvüutşsrqpöonmlkjiıhğgfedçcba" ElseIf say = 3 Then secenek &= Convert.ToInt32(t) & ":öonmlkjiıhğgfedçcbazyxwvüutşsrqp" say = 0 End If Next YeniSifreTxt1.Text = secenek Timer1.Interval = 2000 Timer1.Start() Label4.Text = "Kodlandı" YeniSifreyKaydet() End If End Sub Public Sub YeniSifreyKaydet() Dim regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", True) regkey.CreateSubKey("unknown") Dim subregkey As RegistryKey = regkey.OpenSubKey("unknown", True) subregkey.SetValue("watchword", YeniSifreTxt1.Text) subregkey.Close() regkey.Close() End Sub Public Sub DomainKodla() Application.DoEvents() For Each t In TextSonu.Text say += 1 If say = 1 Then secenek &= Convert.ToInt32(t) & ":abcçdefgğhıijklmnoöpqrsştuüvwxyz" ElseIf say = 2 Then secenek &= Convert.ToInt32(t) & ":zyxwvüutşsrqpöonmlkjiıhğgfedçcba" ElseIf say = 3 Then secenek &= Convert.ToInt32(t) & ":öonmlkjiıhğgfedçcbazyxwvüutşsrqp" say = 0 End If Next YeniSifreTxt1.Text = secenek End Sub Private Sub EskiSifreTxt_KeyDown(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles EskiSifreTxt.KeyDown 'Kısa yoldab ve gizlice eski parolayı hatırlatma (watchword=parola)-(unknown=bilinmeyen) If (e.Alt AndAlso e.KeyCode = Keys.S) Then Dim regkey As RegistryKey = Registry.CurrentUser.OpenSubKey("SOFTWARE", False) Dim subregkey As RegistryKey = regkey.OpenSubKey("unknown", False) sifre = subregkey.GetValue("watchword", Environment.UserDomainName.ToString) Call SifreliKoduCoz() Me.Text = sifre Timer1.Interval = 2000 Timer1.Start() subregkey.Close() regkey.Close() End If End Sub Private Sub EskiSifreTxt_TextChanged(sender As System.Object, e As System.EventArgs) Handles EskiSifreTxt.TextChanged If Me.EskiSifreTxt.Text = sifre Then ParolaKaydetBtn.Enabled = True End If End Sub Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick Me.Text = "Şifre Değiştir" Label4.Text = "" Timer1.Stop() End Sub End Class
Modul :
Module Module1 Public ButunTxt, secenek, u As String Public DsyAdi As String Public TextSonu As New TextBox Public y As Int32 Public say As Int32 Public sifre As String Public sayac As Integer = 0 Public TxtOku As IO.StreamReader Public Yaz As IO.StreamWriter End Module
3 Kasım 2013 Pazar
Form Köşelerini Oval Yapma Kodları
Oto Ekspertiz Cihazları hakkında bilgi almak isterseniz
burayı
tıklayın
Imports System.Drawing.Color Public Class Form1 #Region " windows mesajı" Const TEST_ET As Integer = &H84 Const YAKALA As Integer = &H1 Const BASLIK As Integer = &H2 #End Region Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message) Select Case m.Msg Case TEST_ET MyBase.WndProc(m) If m.Result = YAKALA Then m.Result = BASLIK Case Else MyBase.WndProc(m) End Select End Sub 'FORMU YUVARLAK YAPMAK 'Private Sub Mesaj_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint ' Dim Tempshape As New System.Drawing.Drawing2D.GraphicsPath() ' Tempshape.AddEllipse(0, 0, Me.Width, Me.Height) ' Me.Region = New System.Drawing.Region(Tempshape) 'End Sub 'KÖŞELERİNİ OVAL YAPMAK Private Declare Function SetWindowRgn Lib "user32" (ByVal hWnd As Integer, ByVal hRgn As Integer, ByVal bRedraw As Integer) As Integer Private Declare Function CreateRoundRectRgn Lib "gdi32" Alias "CreateRoundRectRgn" (ByVal X1 As Integer, ByVal Y1 As Integer, ByVal X2 As Integer, ByVal Y2 As Integer, ByVal X3 As Integer, ByVal Y3 As Integer) As Integer Private Sub Mesaj_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load SetWindowRgn(Me.Handle, CreateRoundRectRgn(0, 0, Me.Width, Me.Height, 32, 32), True) End Sub Private Function Control() As Color Throw New NotImplementedException End Function Private Sub Button1_MouseDown(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles Button1.MouseDown If e.Button = Windows.Forms.MouseButtons.Right Then Me.Close() Else If Me.BackColor = Color.Red Then Me.BackColor = Color.RoyalBlue Else Me.BackColor = Red End If End If End Sub Private Sub Button1_MouseLeave(sender As System.Object, e As System.EventArgs) Handles Button1.MouseLeave Dim tooltip As New ToolTip() tooltip.SetToolTip(Button1, "Kapatmak için sağfare tuşunu kullan") End Sub Private Sub Form1_DoubleClick(sender As System.Object, e As System.EventArgs) Handles MyBase.DoubleClick Me.Close() End Sub End Class
Yoldan Fonksiyonla Dosya Adı Bulmak
KOD İNDİR
Imports vb = Microsoft.VisualBasic Public Class Form1 'Public uri As New Uri(TextBox3.text) Private siteadi As String Public Function DosyaAdıBul(ByVal DosyaYolu As String) As String On Error Resume Next Dim SonPozisyon, Yenipozisyon As Integer, Filtre As String SonPozisyon = InStr(DosyaYolu, "\") Yenipozisyon = SonPozisyon Do While SonPozisyon > 0 Yenipozisyon = SonPozisyon SonPozisyon = InStr(Yenipozisyon + 1, DosyaYolu, "\") Loop Filtre = Mid(DosyaYolu, Yenipozisyon + 1) SonPozisyon = InStr(Filtre, ".") Yenipozisyon = SonPozisyon Do While SonPozisyon > 0 Yenipozisyon = SonPozisyon SonPozisyon = InStr(Yenipozisyon + 1, Filtre, ".") Loop Filtre = Mid(Filtre, 1, Yenipozisyon - 1) Return Filtre End Function Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click OpenFileDialog1.ShowDialog() DosyaAdıBul(OpenFileDialog1.FileName) Label1.Text = "DOSYA YOLU : " & OpenFileDialog1.FileName TextBox1.Text = DosyaAdıBul(DosyaAdıBul(OpenFileDialog1.FileName)) 'uzantıyı bulan kod Label3.Text = vb.Right(Label1.Text, 3) End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click Dim uri As New Uri(TextBox3.Text) TextBox2.Text = uri.Host 'Dim uri As New Uri(LinkLabel1.Text) ' MessageBox.Show(Uri.Host) 'Linkin içinden alınan Site Adı ' MessageBox.Show(Uri.AbsoluteUri) 'Kopyalanan linkin tamamı ' MessageBox.Show(Uri.AbsolutePath) 'Site adından link sonuna kadar olan kısım ' MessageBox.Show(Uri.OriginalString.Replace(Uri.AbsolutePath, "")) 'Linkin Tamamı End Sub Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load 'LinkLabel1.Text = "http://eraslancemil.googlepages.com/harita" End Sub Private Sub Button3_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click Dim uri As New Uri(TextBox3.Text) TextBox2.Text = "" TextBox2.Text = uri.AbsoluteUri End Sub Private Sub Button4_Click(sender As System.Object, e As System.EventArgs) Handles Button4.Click Dim uri As New Uri(TextBox3.Text) TextBox2.Text = "" TextBox2.Text = uri.AbsolutePath End Sub Private Sub Button5_Click(sender As System.Object, e As System.EventArgs) Handles Button5.Click Dim uri As New Uri(TextBox3.Text) TextBox2.Text = Mid(uri.AbsoluteUri, 1, 8) End Sub End Class
UYGULAMALARIN VERSİONUNU BULMA KODU
Public Class Form1 Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Try Dim openDLG As New OpenFileDialog openDLG.Filter = "Uygulama (*.exe)|*.exe" If openDLG.ShowDialog = DialogResult.OK Then Dim versionInfo As FileVersionInfo = System.Diagnostics.FileVersionInfo.GetVersionInfo(openDLG.FileName) Debug.Print(versionInfo.FileVersion) Label1.Text = (openDLG.FileName & " version-" & versionInfo.FileVersion) Label2.Text = System.IO.Path.GetFileName(openDLG.FileNames(0)) End If Catch exc As Exception MessageBox.Show(exc.Message, " Error", MessageBoxButtons.OK, MessageBoxIcon.Error) End Try End Sub End Class
Daha Yeni Kayıtlar
Önceki Kayıtlar
Ana Sayfa
Kaydol:
Kayıtlar (Atom)