Προς το περιεχόμενο

Registry + Visual Baisc


tefra

Προτεινόμενες αναρτήσεις

Δημοσ.

καλησπερα παιδες θελω να μαθω πως μεσα απο την Visual basic μπορω να διαχειριζομαι τα dwords Της Registry . Για παραδειγμα για το πειραγμα των μεγιστων ταυτοχρονων downloads το dword ειναι καπως ετσι 0000000a

ομως σε παρενθεση (μεσω του regedit) σου λεει ποσο ακριβως ειναι αυτο (10) στην δικια μας περιπτωση

 

[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings]

"MaxConnectionsPer1_0Server"=dword:0000000a

"MaxConnectionsPerServer"=dword:0000000a

 

εγω λοιπον θελω να κανω ενα προγραμμα για να το αλλαζω αυτο αλλα οχι να γραφω 0000000a αλλα τον συγκεκριμενο αριθμο 10 και να το σωζει μεχρι στιγμης εχω κανει αυτο αλλα δεν λειτουργει κανονικα

που εχω λαθος

 

Private Sub Command1_Click()

Res = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Internet Settings", keyHwnd)

RegSetValueEx keyHwnd, "MaxConnectionsPer1_0Server", 0&, REG_DWORD, Len(Text1.Text), 4

RegCloseKey keyHwnd

Res = RegOpenKey(HKEY_CURRENT_USER, "Software\Microsoft\Windows\CurrentVersion\Internet Settings", keyHwnd)

RegSetValueEx keyHwnd, "MaxConnectionsPerServer", 0&, REG_DWORD, Len(Text3.Text), 4

RegCloseKey keyHwnd

End Sub

 

επισης θελω να μαθω πως σε ενα Label γινεται να αναγραφεται η τιμη ενος dword , string , ή οποιαδηποτε αλλη τιμη της registry

 

οι μεταβλητες και τα απαιτηουμενα api υπαρχουν αλλα δεν τα δημοσιευσα εδω για λογους μεγεθους ,

επειδη στο θεμα Registry + Visual Baisc ειμαι λιγο Noob εχετε να δωσετε καποιο Tutorial αλλα να περιεχει τα παντα dwords , strings , binary , τα παντα !

Δημοσ.
εγω λοιπον θελω να κανω ενα προγραμμα για να το αλλαζω αυτο αλλα οχι να γραφω 0000000a αλλα τον συγκεκριμενο αριθμο 10 και να το σωζει μεχρι στιγμης εχω κανει αυτο αλλα δεν λειτουργει κανονικα

που εχω λαθος

 

Τοτε χρησιμοποιησε την savesetting για να αποθηκευσεις κατι στην registry και την getsetting για να την διαβασεις. Υπαρχει και η deletesetting αν θελεις να σβησεις καποια καταχωρηση απο την registry.

Εγω μονο αυτες χρησιμοποιω. Ψαξε στην βοηθεια του MSDN για να δεις την συνταξη τους.

  • 4 εβδομάδες αργότερα...
Δημοσ.

κάνε copy το κείμενο σε ένα καινούργιο project VB.NET στη φόρμα και λογικά θα πρέπει να σου παίξει. Αν όχι pm me.

 

 

 

 

>
Imports Microsoft.Win32
Public Class Form1
   Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

   Public Sub New()
       MyBase.New()

       'This call is required by the Windows Form Designer.
       InitializeComponent()

       'Add any initialization after the InitializeComponent() call

   End Sub

   'Form overrides dispose to clean up the component list.
   Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
       If disposing Then
           If Not (components Is Nothing) Then
               components.Dispose()
           End If
       End If
       MyBase.Dispose(disposing)
   End Sub

   'Required by the Windows Form Designer
   Private components As System.ComponentModel.IContainer

   'NOTE: The following procedure is required by the Windows Form Designer
   'It can be modified using the Windows Form Designer.  
   'Do not modify it using the code editor.
   Friend WithEvents Button1 As System.Windows.Forms.Button
   Friend WithEvents Button2 As System.Windows.Forms.Button
   Friend WithEvents TextBox2 As System.Windows.Forms.TextBox
   Friend WithEvents TextBox1 As System.Windows.Forms.TextBox
   Friend WithEvents TextBox3 As System.Windows.Forms.TextBox
   Friend WithEvents Label1 As System.Windows.Forms.Label
   Friend WithEvents Label2 As System.Windows.Forms.Label
   Friend WithEvents Label3 As System.Windows.Forms.Label
   Friend WithEvents Label4 As System.Windows.Forms.Label
   Friend WithEvents TextBox4 As System.Windows.Forms.TextBox
   Friend WithEvents GroupBox1 As System.Windows.Forms.GroupBox
   Friend WithEvents GroupBox2 As System.Windows.Forms.GroupBox
   Friend WithEvents Label5 As System.Windows.Forms.Label
   <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
       Me.Button1 = New System.Windows.Forms.Button
       Me.Button2 = New System.Windows.Forms.Button
       Me.TextBox2 = New System.Windows.Forms.TextBox
       Me.TextBox1 = New System.Windows.Forms.TextBox
       Me.TextBox3 = New System.Windows.Forms.TextBox
       Me.Label1 = New System.Windows.Forms.Label
       Me.Label2 = New System.Windows.Forms.Label
       Me.Label3 = New System.Windows.Forms.Label
       Me.Label4 = New System.Windows.Forms.Label
       Me.TextBox4 = New System.Windows.Forms.TextBox
       Me.GroupBox1 = New System.Windows.Forms.GroupBox
       Me.GroupBox2 = New System.Windows.Forms.GroupBox
       Me.Label5 = New System.Windows.Forms.Label
       Me.GroupBox1.SuspendLayout()
       Me.GroupBox2.SuspendLayout()
       Me.SuspendLayout()
       '
       'Button1
       '
       Me.Button1.Location = New System.Drawing.Point(280, 32)
       Me.Button1.Name = "Button1"
       Me.Button1.TabIndex = 2
       Me.Button1.Text = "Read Reg"
       '
       'Button2
       '
       Me.Button2.Location = New System.Drawing.Point(280, 32)
       Me.Button2.Name = "Button2"
       Me.Button2.TabIndex = 2
       Me.Button2.Text = "Write Reg"
       '
       'TextBox2
       '
       Me.TextBox2.Location = New System.Drawing.Point(176, 48)
       Me.TextBox2.Name = "TextBox2"
       Me.TextBox2.TabIndex = 1
       Me.TextBox2.Text = "12"
       '
       'TextBox1
       '
       Me.TextBox1.Location = New System.Drawing.Point(176, 48)
       Me.TextBox1.Name = "TextBox1"
       Me.TextBox1.ReadOnly = True
       Me.TextBox1.TabIndex = 1
       Me.TextBox1.Text = ""
       '
       'TextBox3
       '
       Me.TextBox3.Location = New System.Drawing.Point(176, 24)
       Me.TextBox3.Name = "TextBox3"
       Me.TextBox3.TabIndex = 0
       Me.TextBox3.Text = "10"
       '
       'Label1
       '
       Me.Label1.Location = New System.Drawing.Point(8, 24)
       Me.Label1.Name = "Label1"
       Me.Label1.Size = New System.Drawing.Size(144, 16)
       Me.Label1.TabIndex = 3
       Me.Label1.Text = "MaxConnectionsPerServer"
       '
       'Label2
       '
       Me.Label2.Location = New System.Drawing.Point(8, 48)
       Me.Label2.Name = "Label2"
       Me.Label2.Size = New System.Drawing.Size(160, 16)
       Me.Label2.TabIndex = 4
       Me.Label2.Text = "MaxConnectionsPer1_0Server"
       '
       'Label3
       '
       Me.Label3.Location = New System.Drawing.Point(8, 48)
       Me.Label3.Name = "Label3"
       Me.Label3.Size = New System.Drawing.Size(160, 16)
       Me.Label3.TabIndex = 4
       Me.Label3.Text = "MaxConnectionsPer1_0Server"
       '
       'Label4
       '
       Me.Label4.Location = New System.Drawing.Point(8, 24)
       Me.Label4.Name = "Label4"
       Me.Label4.Size = New System.Drawing.Size(144, 16)
       Me.Label4.TabIndex = 3
       Me.Label4.Text = "MaxConnectionsPerServer"
       '
       'TextBox4
       '
       Me.TextBox4.Location = New System.Drawing.Point(176, 24)
       Me.TextBox4.Name = "TextBox4"
       Me.TextBox4.ReadOnly = True
       Me.TextBox4.TabIndex = 0
       Me.TextBox4.Text = ""
       '
       'GroupBox1
       '
       Me.GroupBox1.Controls.Add(Me.Label4)
       Me.GroupBox1.Controls.Add(Me.Button1)
       Me.GroupBox1.Controls.Add(Me.Label3)
       Me.GroupBox1.Controls.Add(Me.TextBox1)
       Me.GroupBox1.Controls.Add(Me.TextBox4)
       Me.GroupBox1.Location = New System.Drawing.Point(4, 104)
       Me.GroupBox1.Name = "GroupBox1"
       Me.GroupBox1.Size = New System.Drawing.Size(368, 80)
       Me.GroupBox1.TabIndex = 1
       Me.GroupBox1.TabStop = False
       Me.GroupBox1.Text = "Read Registry"
       '
       'GroupBox2
       '
       Me.GroupBox2.Controls.Add(Me.TextBox3)
       Me.GroupBox2.Controls.Add(Me.Label1)
       Me.GroupBox2.Controls.Add(Me.Button2)
       Me.GroupBox2.Controls.Add(Me.TextBox2)
       Me.GroupBox2.Controls.Add(Me.Label2)
       Me.GroupBox2.Location = New System.Drawing.Point(4, 0)
       Me.GroupBox2.Name = "GroupBox2"
       Me.GroupBox2.Size = New System.Drawing.Size(368, 88)
       Me.GroupBox2.TabIndex = 0
       Me.GroupBox2.TabStop = False
       Me.GroupBox2.Text = "Write Registry"
       '
       'Label5
       '
       Me.Label5.Location = New System.Drawing.Point(36, 192)
       Me.Label5.Name = "Label5"
       Me.Label5.Size = New System.Drawing.Size(304, 16)
       Me.Label5.TabIndex = 2
       Me.Label5.Text = "Δημιουργήθηκε από τον Μελεσανάκη Γεώργιο στις 29-7-04"
       '
       'Form1
       '
       Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
       Me.ClientSize = New System.Drawing.Size(376, 222)
       Me.Controls.Add(Me.Label5)
       Me.Controls.Add(Me.GroupBox2)
       Me.Controls.Add(Me.GroupBox1)
       Me.Name = "Form1"
       Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
       Me.Text = "Form1"
       Me.GroupBox1.ResumeLayout(False)
       Me.GroupBox2.ResumeLayout(False)
       Me.ResumeLayout(False)

   End Sub

#End Region

   Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

       Dim regVersion As RegistryKey
       regVersion = Registry.CurrentUser.OpenSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings", True)
       If regVersion Is Nothing Then
           ' Key doesn't exist; create it.
           regVersion = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings")
       End If

       Dim intVersion1_0 As Integer = 0
       Dim intVersion As Integer = 0
       If (Not regVersion Is Nothing) Then
           intVersion = regVersion.GetValue("MaxConnectionsPerServer", 0)
           intVersion1_0 = intVersion1_0 + TextBox2.Text
           intVersion = intVersion + TextBox3.Text
           regVersion.SetValue("MaxConnectionsPer1_0Server", intVersion1_0)
           regVersion.SetValue("MaxConnectionsPerServer", intVersion)
           regVersion.Close()
       End If

       MessageBox.Show("Οι απαραίτητες αλλαγές πραγματοποιήθηκαν.", "Επιτυχία", MessageBoxButtons.OK, MessageBoxIcon.Asterisk)
   End Sub

   Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
       Dim RegKey As RegistryKey
       RegKey = Registry.CurrentUser.CreateSubKey("Software\Microsoft\Windows\CurrentVersion\Internet Settings")
       TextBox1.Text = RegKey.GetValue("MaxConnectionsPer1_0Server")
       TextBox4.Text = RegKey.GetValue("MaxConnectionsPerServer")

   End Sub
End Class

 

Edited by Dionisos: Vazete panta ton kwdika se code tags

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...