home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 21 / IOPROG_21.ISO / SOFT / EASYREG.ZIP / Example.Frm (.txt) < prev    next >
Encoding:
Visual Basic Form  |  1997-09-04  |  25.3 KB  |  790 lines

  1. VERSION 5.00
  2. Begin VB.Form frmDirectory 
  3.    BorderStyle     =   1  'Fixed Single
  4.    Caption         =   "Registry Directory"
  5.    ClientHeight    =   6780
  6.    ClientLeft      =   588
  7.    ClientTop       =   324
  8.    ClientWidth     =   8688
  9.    Icon            =   "Example.frx":0000
  10.    LinkTopic       =   "Form1"
  11.    LockControls    =   -1  'True
  12.    MaxButton       =   0   'False
  13.    PaletteMode     =   1  'UseZOrder
  14.    ScaleHeight     =   6780
  15.    ScaleWidth      =   8688
  16.    Begin VB.CommandButton cmdDeleteKey 
  17.       Caption         =   "Delete Key"
  18.       BeginProperty Font 
  19.          Name            =   "MS Sans Serif"
  20.          Size            =   12
  21.          Charset         =   0
  22.          Weight          =   700
  23.          Underline       =   0   'False
  24.          Italic          =   0   'False
  25.          Strikethrough   =   0   'False
  26.       EndProperty
  27.       Height          =   492
  28.       Left            =   2040
  29.       TabIndex        =   29
  30.       Top             =   5760
  31.       Width           =   1932
  32.    End
  33.    Begin VB.CommandButton cmdNewKey 
  34.       Caption         =   "New Key"
  35.       BeginProperty Font 
  36.          Name            =   "MS Sans Serif"
  37.          Size            =   12
  38.          Charset         =   0
  39.          Weight          =   700
  40.          Underline       =   0   'False
  41.          Italic          =   0   'False
  42.          Strikethrough   =   0   'False
  43.       EndProperty
  44.       Height          =   492
  45.       Left            =   120
  46.       TabIndex        =   28
  47.       Top             =   5760
  48.       Width           =   1452
  49.    End
  50.    Begin VB.CommandButton cmdDeleteValue 
  51.       Caption         =   "Delete Value"
  52.       BeginProperty Font 
  53.          Name            =   "MS Sans Serif"
  54.          Size            =   12
  55.          Charset         =   0
  56.          Weight          =   700
  57.          Underline       =   0   'False
  58.          Italic          =   0   'False
  59.          Strikethrough   =   0   'False
  60.       EndProperty
  61.       Height          =   492
  62.       Left            =   6720
  63.       TabIndex        =   27
  64.       Top             =   6204
  65.       Width           =   1824
  66.    End
  67.    Begin VB.CommandButton cmdNewValueName 
  68.       Caption         =   "New Value"
  69.       BeginProperty Font 
  70.          Name            =   "MS Sans Serif"
  71.          Size            =   12
  72.          Charset         =   0
  73.          Weight          =   700
  74.          Underline       =   0   'False
  75.          Italic          =   0   'False
  76.          Strikethrough   =   0   'False
  77.       EndProperty
  78.       Height          =   492
  79.       Left            =   4200
  80.       TabIndex        =   26
  81.       Top             =   5520
  82.       Width           =   1452
  83.    End
  84.    Begin VB.Frame fraType 
  85.       Caption         =   "Type"
  86.       Height          =   732
  87.       Left            =   5760
  88.       TabIndex        =   22
  89.       Top             =   5040
  90.       Width           =   2892
  91.       Begin VB.OptionButton optType 
  92.          Caption         =   "DWord"
  93.          Height          =   288
  94.          Index           =   2
  95.          Left            =   1836
  96.          TabIndex        =   25
  97.          Top             =   264
  98.          Value           =   -1  'True
  99.          Width           =   972
  100.       End
  101.       Begin VB.OptionButton optType 
  102.          Caption         =   "Bytes"
  103.          Height          =   372
  104.          Index           =   1
  105.          Left            =   972
  106.          TabIndex        =   24
  107.          Top             =   216
  108.          Width           =   852
  109.       End
  110.       Begin VB.OptionButton optType 
  111.          Caption         =   "String"
  112.          Height          =   408
  113.          Index           =   0
  114.          Left            =   108
  115.          TabIndex        =   23
  116.          Top             =   204
  117.          Width           =   852
  118.       End
  119.    End
  120.    Begin VB.CommandButton cmdSetValue 
  121.       Caption         =   "Set Value"
  122.       Enabled         =   0   'False
  123.       BeginProperty Font 
  124.          Name            =   "MS Sans Serif"
  125.          Size            =   12
  126.          Charset         =   0
  127.          Weight          =   700
  128.          Underline       =   0   'False
  129.          Italic          =   0   'False
  130.          Strikethrough   =   0   'False
  131.       EndProperty
  132.       Height          =   492
  133.       Left            =   4200
  134.       TabIndex        =   21
  135.       Top             =   4920
  136.       Width           =   1452
  137.    End
  138.    Begin VB.TextBox txtValueDbl 
  139.       Height          =   372
  140.       Left            =   5160
  141.       TabIndex        =   17
  142.       Top             =   4320
  143.       Width           =   1452
  144.    End
  145.    Begin VB.TextBox txtValueByt 
  146.       Height          =   492
  147.       Left            =   5160
  148.       MultiLine       =   -1  'True
  149.       ScrollBars      =   1  'Horizontal
  150.       TabIndex        =   16
  151.       Top             =   3720
  152.       Width           =   3372
  153.    End
  154.    Begin VB.TextBox txtValueType 
  155.       Height          =   300
  156.       Left            =   5160
  157.       TabIndex        =   15
  158.       Top             =   2760
  159.       Width           =   1452
  160.    End
  161.    Begin VB.TextBox txtValueStr 
  162.       Height          =   492
  163.       Left            =   5160
  164.       MultiLine       =   -1  'True
  165.       ScrollBars      =   1  'Horizontal
  166.       TabIndex        =   14
  167.       Top             =   3120
  168.       Width           =   3372
  169.    End
  170.    Begin VB.ComboBox cboValueName 
  171.       Height          =   288
  172.       Left            =   5160
  173.       Sorted          =   -1  'True
  174.       Style           =   2  'Dropdown List
  175.       TabIndex        =   12
  176.       Top             =   2400
  177.       Width           =   3372
  178.    End
  179.    Begin VB.ComboBox cboKeyDirectory 
  180.       Height          =   288
  181.       Left            =   4680
  182.       Sorted          =   -1  'True
  183.       Style           =   2  'Dropdown List
  184.       TabIndex        =   9
  185.       Top             =   1800
  186.       Width           =   3864
  187.    End
  188.    Begin VB.ListBox lstValueDirectory 
  189.       Height          =   1392
  190.       ItemData        =   "Example.frx":0442
  191.       Left            =   120
  192.       List            =   "Example.frx":0449
  193.       Sorted          =   -1  'True
  194.       TabIndex        =   6
  195.       Top             =   4200
  196.       Width           =   3852
  197.    End
  198.    Begin VB.CommandButton cmdCdRoot 
  199.       Caption         =   "CD \"
  200.       BeginProperty Font 
  201.          Name            =   "MS Sans Serif"
  202.          Size            =   12
  203.          Charset         =   0
  204.          Weight          =   700
  205.          Underline       =   0   'False
  206.          Italic          =   0   'False
  207.          Strikethrough   =   0   'False
  208.       EndProperty
  209.       Height          =   492
  210.       Left            =   5760
  211.       TabIndex        =   5
  212.       Top             =   1200
  213.       Width           =   1452
  214.    End
  215.    Begin VB.CommandButton cmdCdUp 
  216.       Caption         =   "CD .."
  217.       BeginProperty Font 
  218.          Name            =   "MS Sans Serif"
  219.          Size            =   12
  220.          Charset         =   0
  221.          Weight          =   700
  222.          Underline       =   0   'False
  223.          Italic          =   0   'False
  224.          Strikethrough   =   0   'False
  225.       EndProperty
  226.       Height          =   492
  227.       Left            =   4200
  228.       TabIndex        =   4
  229.       Top             =   1200
  230.       Width           =   1452
  231.    End
  232.    Begin VB.ListBox lstKeyDirectory 
  233.       Height          =   1776
  234.       ItemData        =   "Example.frx":0460
  235.       Left            =   120
  236.       List            =   "Example.frx":0467
  237.       Sorted          =   -1  'True
  238.       TabIndex        =   3
  239.       Top             =   2040
  240.       Width           =   3852
  241.    End
  242.    Begin VB.CommandButton cmdDir 
  243.       Caption         =   "Dir"
  244.       BeginProperty Font 
  245.          Name            =   "MS Sans Serif"
  246.          Size            =   12
  247.          Charset         =   0
  248.          Weight          =   700
  249.          Underline       =   0   'False
  250.          Italic          =   0   'False
  251.          Strikethrough   =   0   'False
  252.       EndProperty
  253.       Height          =   492
  254.       Left            =   120
  255.       TabIndex        =   2
  256.       Top             =   1200
  257.       Width           =   2532
  258.    End
  259.    Begin VB.TextBox txtCurrentDirectory 
  260.       Height          =   492
  261.       Left            =   120
  262.       MultiLine       =   -1  'True
  263.       ScrollBars      =   1  'Horizontal
  264.       TabIndex        =   1
  265.       Text            =   "Example.frx":047C
  266.       Top             =   480
  267.       Width           =   8412
  268.    End
  269.    Begin VB.Line Line4 
  270.       BorderColor     =   &H00E0E0E0&
  271.       Index           =   2
  272.       X1              =   4236
  273.       X2              =   8580
  274.       Y1              =   6108
  275.       Y2              =   6108
  276.    End
  277.    Begin VB.Line Line3 
  278.       Index           =   2
  279.       X1              =   4236
  280.       X2              =   8580
  281.       Y1              =   6096
  282.       Y2              =   6096
  283.    End
  284.    Begin VB.Line Line3 
  285.       Index           =   1
  286.       X1              =   4236
  287.       X2              =   8580
  288.       Y1              =   4788
  289.       Y2              =   4788
  290.    End
  291.    Begin VB.Line Line4 
  292.       BorderColor     =   &H00E0E0E0&
  293.       Index           =   1
  294.       X1              =   4236
  295.       X2              =   8580
  296.       Y1              =   4800
  297.       Y2              =   4800
  298.    End
  299.    Begin VB.Label Label7 
  300.       Caption         =   "Number"
  301.       BeginProperty Font 
  302.          Name            =   "MS Sans Serif"
  303.          Size            =   9.6
  304.          Charset         =   0
  305.          Weight          =   400
  306.          Underline       =   0   'False
  307.          Italic          =   0   'False
  308.          Strikethrough   =   0   'False
  309.       EndProperty
  310.       Height          =   252
  311.       Index           =   2
  312.       Left            =   4200
  313.       TabIndex        =   20
  314.       Top             =   4440
  315.       Width           =   972
  316.    End
  317.    Begin VB.Label Label7 
  318.       Caption         =   "Bytes"
  319.       BeginProperty Font 
  320.          Name            =   "MS Sans Serif"
  321.          Size            =   9.6
  322.          Charset         =   0
  323.          Weight          =   400
  324.          Underline       =   0   'False
  325.          Italic          =   0   'False
  326.          Strikethrough   =   0   'False
  327.       EndProperty
  328.       Height          =   252
  329.       Index           =   1
  330.       Left            =   4200
  331.       TabIndex        =   19
  332.       Top             =   3804
  333.       Width           =   732
  334.    End
  335.    Begin VB.Label Label7 
  336.       Caption         =   "String"
  337.       BeginProperty Font 
  338.          Name            =   "MS Sans Serif"
  339.          Size            =   9.6
  340.          Charset         =   0
  341.          Weight          =   400
  342.          Underline       =   0   'False
  343.          Italic          =   0   'False
  344.          Strikethrough   =   0   'False
  345.       EndProperty
  346.       Height          =   252
  347.       Index           =   0
  348.       Left            =   4200
  349.       TabIndex        =   18
  350.       Top             =   3240
  351.       Width           =   732
  352.    End
  353.    Begin VB.Label Label6 
  354.       Caption         =   "Type"
  355.       BeginProperty Font 
  356.          Name            =   "MS Sans Serif"
  357.          Size            =   9.6
  358.          Charset         =   0
  359.          Weight          =   700
  360.          Underline       =   0   'False
  361.          Italic          =   0   'False
  362.          Strikethrough   =   0   'False
  363.       EndProperty
  364.       Height          =   252
  365.       Left            =   4560
  366.       TabIndex        =   13
  367.       Top             =   2760
  368.       Width           =   612
  369.    End
  370.    Begin VB.Label Label5 
  371.       Caption         =   "ValueOf"
  372.       BeginProperty Font 
  373.          Name            =   "MS Sans Serif"
  374.          Size            =   9.6
  375.          Charset         =   0
  376.          Weight          =   700
  377.          Underline       =   0   'False
  378.          Italic          =   0   'False
  379.          Strikethrough   =   0   'False
  380.       EndProperty
  381.       Height          =   252
  382.       Left            =   4200
  383.       TabIndex        =   11
  384.       Top             =   2400
  385.       Width           =   924
  386.    End
  387.    Begin VB.Line Line4 
  388.       BorderColor     =   &H00E0E0E0&
  389.       Index           =   0
  390.       X1              =   4212
  391.       X2              =   8556
  392.       Y1              =   2256
  393.       Y2              =   2256
  394.    End
  395.    Begin VB.Line Line3 
  396.       Index           =   0
  397.       X1              =   4212
  398.       X2              =   8556
  399.       Y1              =   2244
  400.       Y2              =   2244
  401.    End
  402.    Begin VB.Label Label4 
  403.       Caption         =   "CD"
  404.       BeginProperty Font 
  405.          Name            =   "MS Sans Serif"
  406.          Size            =   9.6
  407.          Charset         =   0
  408.          Weight          =   700
  409.          Underline       =   0   'False
  410.          Italic          =   0   'False
  411.          Strikethrough   =   0   'False
  412.       EndProperty
  413.       Height          =   252
  414.       Left            =   4200
  415.       TabIndex        =   10
  416.       Top             =   1800
  417.       Width           =   372
  418.    End
  419.    Begin VB.Line Line2 
  420.       BorderColor     =   &H00E0E0E0&
  421.       X1              =   4080
  422.       X2              =   4080
  423.       Y1              =   1236
  424.       Y2              =   6684
  425.    End
  426.    Begin VB.Line Line1 
  427.       X1              =   4068
  428.       X2              =   4068
  429.       Y1              =   1224
  430.       Y2              =   6684
  431.    End
  432.    Begin VB.Label Label3 
  433.       Caption         =   "Value Names"
  434.       BeginProperty Font 
  435.          Name            =   "MS Sans Serif"
  436.          Size            =   9.6
  437.          Charset         =   0
  438.          Weight          =   700
  439.          Underline       =   0   'False
  440.          Italic          =   0   'False
  441.          Strikethrough   =   0   'False
  442.       EndProperty
  443.       Height          =   252
  444.       Left            =   120
  445.       TabIndex        =   8
  446.       Top             =   3960
  447.       Width           =   2052
  448.    End
  449.    Begin VB.Label Label2 
  450.       Caption         =   "Keys"
  451.       BeginProperty Font 
  452.          Name            =   "MS Sans Serif"
  453.          Size            =   9.6
  454.          Charset         =   0
  455.          Weight          =   700
  456.          Underline       =   0   'False
  457.          Italic          =   0   'False
  458.          Strikethrough   =   0   'False
  459.       EndProperty
  460.       Height          =   252
  461.       Left            =   120
  462.       TabIndex        =   7
  463.       Top             =   1800
  464.       Width           =   852
  465.    End
  466.    Begin VB.Label Label1 
  467.       Caption         =   "Current Directory"
  468.       BeginProperty Font 
  469.          Name            =   "MS Sans Serif"
  470.          Size            =   9.6
  471.          Charset         =   0
  472.          Weight          =   700
  473.          Underline       =   0   'False
  474.          Italic          =   0   'False
  475.          Strikethrough   =   0   'False
  476.       EndProperty
  477.       Height          =   252
  478.       Left            =   120
  479.       TabIndex        =   0
  480.       Top             =   120
  481.       Width           =   2028
  482.    End
  483. Attribute VB_Name = "frmDirectory"
  484. Attribute VB_GlobalNameSpace = False
  485. Attribute VB_Creatable = False
  486. Attribute VB_PredeclaredId = True
  487. Attribute VB_Exposed = False
  488. Option Explicit
  489. Const REG_SZ = 1
  490. Const REG_BINARY = 3
  491. Const REG_DWORD = 4
  492. ' -- Set RO a Textbox
  493. Const WM_USER = &H400
  494. Const EM_SETREADONLY = (WM_USER + 31)
  495. Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Long) As Long
  496. Private Sub Form_Load()
  497.   SendMessage txtCurrentDirectory.hwnd, EM_SETREADONLY, 1, 0
  498.   SendMessage txtValueType.hwnd, EM_SETREADONLY, 1, 0
  499.   SendMessage txtValueStr.hwnd, EM_SETREADONLY, 1, 0
  500.   SendMessage txtValueByt.hwnd, EM_SETREADONLY, 1, 0
  501.   SendMessage txtValueDbl.hwnd, EM_SETREADONLY, 1, 0
  502.   txtCurrentDirectory = ""
  503.   #If Test Then
  504.     Cd "\HKEY_CURRENT_USER\SOFTWARE\VB AND VBA PROGRAM SETTINGS\LM CANCELLA"
  505.     txtCurrentDirectory = CurrentKey
  506.   #End If
  507.   cmdDir.Value = True
  508. End Sub
  509. Private Sub cmdDir_Click()
  510. Dim astrResult As Variant
  511. Dim lngJ As Long
  512. Dim strValueType As String
  513.   MousePointer = vbHourglass
  514.   lstKeyDirectory.Clear
  515.   cboKeyDirectory.Clear
  516.   lstValueDirectory.Clear
  517.   cboValueName.Clear
  518.   cmdSetValue.Enabled = False
  519.   cmdDeleteValue.Enabled = False
  520.   cmdNewValueName.Enabled = False
  521.   cmdNewKey.Enabled = False
  522.   cmdDeleteKey.Enabled = False
  523.   txtValueType = ""
  524.   txtValueStr = ""
  525.   txtValueByt = ""
  526.   txtValueDbl = ""
  527.   If txtCurrentDirectory <> "" Then
  528.     cmdNewKey.Enabled = True
  529.     cmdDeleteKey.Enabled = True
  530.     cmdNewValueName.Enabled = True
  531.   End If
  532.   astrResult = DirKey
  533.   If Not IsNull(astrResult) Then
  534.     For lngJ = LBound(astrResult) To UBound(astrResult)
  535.       lstKeyDirectory.AddItem astrResult(lngJ)
  536.       cboKeyDirectory.AddItem astrResult(lngJ)
  537.     Next
  538.   End If
  539.   astrResult = DirValue
  540.   If Not IsNull(astrResult) Then
  541.     For lngJ = LBound(astrResult, 2) To UBound(astrResult, 2)
  542.       Select Case astrResult(erValueType, lngJ)
  543.         Case erByte
  544.            strValueType = "BYTE"
  545.         Case erDWord
  546.           strValueType = "DWORD"
  547.         Case Else
  548.           strValueType = "STRING"
  549.       End Select
  550.       lstValueDirectory.AddItem astrResult(erValueName, lngJ) & "|(" & strValueType & ")" & "|" & astrResult(erValue, lngJ)
  551.       cboValueName.AddItem astrResult(erValueName, lngJ) & "|(" & strValueType & ")" & "|" & astrResult(erValue, lngJ)
  552.     Next
  553.   End If
  554.   MousePointer = vbDefault
  555. End Sub
  556. Private Sub lstKeyDirectory_DblClick()
  557.   With lstKeyDirectory
  558.     If .ListIndex <> -1 Then _
  559.       Cd .List(.ListIndex)
  560.   End With
  561.   txtCurrentDirectory = CurrentKey
  562.   cmdDir.Value = True
  563. End Sub
  564. Private Sub cboKeyDirectory_Click()
  565.   With cboKeyDirectory
  566.     If .ListIndex <> -1 Then _
  567.       Cd CurrentKey & IIf(CurrentKey = "", "", "\") & .List(.ListIndex)
  568.   End With
  569.   txtCurrentDirectory = CurrentKey
  570.   cmdDir.Value = True
  571. End Sub
  572. Private Sub cboValueName_Click()
  573.   If cboValueName.ListIndex <> -1 Then _
  574.     FillValue (cboValueName.List(cboValueName.ListIndex))
  575. End Sub
  576. Private Sub lstValueDirectory_DblClick()
  577.   If lstValueDirectory.ListIndex <> -1 Then _
  578.     cboValueName.ListIndex = lstValueDirectory.ListIndex
  579. End Sub
  580. Private Sub cmdCdUp_Click()
  581.   On Error GoTo cmdCdUp_Click_Err
  582.   Cd ".."
  583.   txtCurrentDirectory = CurrentKey
  584.   cmdDir.Value = True
  585.   Exit Sub
  586. cmdCdUp_Click_Err:
  587.   MsgBox " Number : " & Err.Number & vbCr & _
  588.          " Source : " & Err.Source & vbCr & _
  589.          " Description : " & Err.Description, _
  590.          vbExclamation + vbOKOnly, _
  591.          "Run-Time Error"
  592. End Sub
  593. Private Sub cmdCdRoot_Click()
  594.   Cd "\"
  595.   txtCurrentDirectory = CurrentKey
  596.   cmdDir.Value = True
  597. End Sub
  598. Private Sub cmdSetValue_Click()
  599. Dim strValueName As String
  600. Dim lngValueType As enmDataType
  601. Dim strValue As String
  602. Dim dblValue As Double
  603. Dim abytValue() As Byte
  604. Dim lngI As Long
  605. Dim lngJ As Long
  606. Dim lngIndex As Long
  607. Dim strInput As String
  608.   On Error GoTo cmdSetValue_Err
  609.   lngIndex = cboValueName.ListIndex
  610.   strValueName = cboValueName.List(cboValueName.ListIndex)
  611.   strValueName = Mid(strValueName, 1, InStr(strValueName, "|") - 1)
  612.   If optType(0).Value = True Then
  613.     lngValueType = erSTRING
  614.     strValue = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  615.                         "Insert a STRING value", "SET Value")
  616.     If strValue = "" Then GoTo cmdNewValueName_Abort
  617.     ValueOf(strValueName, lngValueType) = strValue
  618.   ElseIf optType(1).Value = True Then
  619.     lngValueType = erByte
  620.     Do
  621.       strInput = InputBox("How many BYTES to enter ?", "SET Value")
  622.       If strInput = "" Then GoTo cmdNewValueName_Abort
  623.     Loop While Not IsNumeric(strInput)
  624.     lngJ = Val(strInput)
  625.     For lngI = 1 To lngJ
  626.       ReDim Preserve abytValue(1 To lngI)
  627.       Do
  628.         strInput = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  629.                             "Insert BYTE value (" & lngI & "/" & lngJ & ")", "SET Value")
  630.         If strInput = "" Then GoTo cmdNewValueName_Abort
  631.       Loop Until IsNumeric(strInput) And Val(strInput) >= 0 And Val(strInput) <= 255
  632.       abytValue(lngI) = CByte(Int(Val(strInput)))
  633.     Next
  634.     ValueOf(strValueName, lngValueType) = abytValue
  635.   Else
  636.     lngValueType = erDWord
  637.     Do
  638.       strInput = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  639.                           "Insert a DWORD value", "SET Value")
  640.       If strInput = "" Then GoTo cmdNewValueName_Abort
  641.     Loop Until IsNumeric(strInput) And Val(strInput) >= 0 And Val(strInput) <= 4294967295#
  642.     dblValue = CDbl(Int(Val(strInput)))
  643.     ValueOf(strValueName, lngValueType) = dblValue
  644.   End If
  645.   cmdDir.Value = True
  646.   cboValueName.ListIndex = lngIndex
  647.   Exit Sub
  648. cmdSetValue_Err:
  649.   MsgBox " Number : " & Err.Number & vbCr & _
  650.          " Source : " & Err.Source & vbCr & _
  651.          " Description : " & Err.Description, _
  652.          vbExclamation + vbOKOnly, _
  653.          "Run-Time Error"
  654.   Exit Sub
  655. cmdNewValueName_Abort:
  656.   Beep
  657. End Sub
  658. Private Sub cmdNewValueName_Click()
  659. Dim strValueName As String
  660. Dim lngValueType As enmDataType
  661. Dim strValue As String
  662. Dim dblValue As Double
  663. Dim abytValue() As Byte
  664. Dim lngI As Long
  665. Dim lngJ As Long
  666. Dim strInput As String
  667.   On Error GoTo cmdNewValueName_Err
  668.   strValueName = InputBox("Insert the NAME of the value " & vbCr & _
  669.                          "you want add in the Registry :", "NEW ValueName=Value")
  670.   If strValueName = "" Then GoTo cmdNewValueName_Abort
  671.   If optType(0).Value = True Then
  672.     lngValueType = erSTRING
  673.     strValue = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  674.                         "Insert a STRING value", "SET Value")
  675.     If strValue = "" Then GoTo cmdNewValueName_Abort
  676.     ValueOf(strValueName, lngValueType) = strValue
  677.   ElseIf optType(1).Value = True Then
  678.     lngValueType = erByte
  679.     Do
  680.       strInput = InputBox("How many BYTES to enter ?", "SET Value")
  681.       If strInput = "" Then GoTo cmdNewValueName_Abort
  682.     Loop While Not IsNumeric(strInput)
  683.     lngJ = Val(strInput)
  684.     For lngI = 1 To lngJ
  685.       ReDim Preserve abytValue(1 To lngI)
  686.       Do
  687.         strInput = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  688.                             "Insert BYTE value (" & lngI & "/" & lngJ & ")", "SET Value")
  689.         If strInput = "" Then GoTo cmdNewValueName_Abort
  690.       Loop Until IsNumeric(strInput) And Val(strInput) >= 0 And Val(strInput) <= 255
  691.       abytValue(lngI) = CByte(Int(Val(strInput)))
  692.     Next
  693.     ValueOf(strValueName, lngValueType) = abytValue
  694.   Else
  695.     lngValueType = erDWord
  696.     Do
  697.       strInput = InputBox("Value Name : " & strValueName & vbCr & vbCr & _
  698.                           "Insert a DWORD value", "SET Value")
  699.       If strInput = "" Then GoTo cmdNewValueName_Abort
  700.     Loop Until IsNumeric(strInput) And Val(strInput) >= 0 And Val(strInput) <= 4294967295#
  701.     dblValue = CDbl(Int(Val(strInput)))
  702.     ValueOf(strValueName, lngValueType) = dblValue
  703.   End If
  704.   cmdDir.Value = True
  705.   Exit Sub
  706. cmdNewValueName_Err:
  707.   MsgBox " Number : " & Err.Number & vbCr & _
  708.          " Source : " & Err.Source & vbCr & _
  709.          " Description : " & Err.Description, _
  710.          vbExclamation + vbOKOnly, _
  711.          "Run-Time Error"
  712.   Exit Sub
  713. cmdNewValueName_Abort:
  714.   Beep
  715. End Sub
  716. Private Sub cmdNewKey_Click()
  717. Dim strValueName As String
  718.   strValueName = InputBox("Insert the NAME of the key " & vbCr & _
  719.                           "you want add in the Registry :", "NEW KEY")
  720.   If strValueName = "" Then GoTo cmdNewKey_Abort
  721.   MakeKey strValueName
  722.   cmdDir.Value = True
  723.   Exit Sub
  724. cmdNewKey_Abort:
  725.   Beep
  726. End Sub
  727. Private Sub cmdDeleteValue_Click()
  728. Dim strValueName As String
  729.   strValueName = cboValueName.List(cboValueName.ListIndex)
  730.   strValueName = Mid(strValueName, 1, InStr(strValueName, "|") - 1)
  731.   DeleteValue strValueName
  732.   cmdDir.Value = True
  733. End Sub
  734. Private Sub cmdDeleteKey_Click()
  735. Dim strKeyName As String
  736. Dim strDefault As String
  737.   If lstKeyDirectory.ListIndex <> -1 Then _
  738.     strDefault = lstKeyDirectory.List(lstKeyDirectory.ListIndex)
  739.   strKeyName = InputBox("Insert the NAME of the key " & vbCr & _
  740.                           "you want DELETE :", "DELETE KEY", strDefault)
  741.   If strKeyName = "" Then GoTo cmdDeleteKey_Abort
  742.   If vbOK = MsgBox("Do you really want " & vbCr & _
  743.             "to delete KEY " & strKeyName & " ?", _
  744.             vbOKCancel Or vbQuestion, "DELETE KEY") Then
  745.     DeleteKey strKeyName
  746.     cmdDir.Value = True
  747.   Else
  748.     GoTo cmdDeleteKey_Abort
  749.   End If
  750.   Exit Sub
  751. cmdDeleteKey_Abort:
  752.   Beep
  753. End Sub
  754. Private Sub FillValue(ByVal strValueName As String)
  755. Const REG_BINARY = 3
  756. Const REG_DWORD = 4
  757. Dim strNome As String
  758. Dim lngValueType As enmDataType
  759. Dim strValueType As String
  760. Dim vntByte As Variant
  761. Dim dblValue As Double
  762. Dim vntReturn As Variant
  763. Dim lngI As Long
  764.   txtValueType = ""
  765.   txtValueStr = ""
  766.   txtValueByt = ""
  767.   txtValueDbl = ""
  768.   vntReturn = ValueOf(Mid(strValueName, 1, InStr(strValueName, "|") - 1), lngValueType)
  769.   txtValueStr = vntReturn(0)
  770.   Select Case lngValueType
  771.     Case erByte
  772.       optType(1).Value = True
  773.        strValueType = "BYTE"
  774.     Case erDWord
  775.       strValueType = "DWORD"
  776.       optType(2).Value = True
  777.     Case Else
  778.       strValueType = "STRING"
  779.       optType(0).Value = True
  780.   End Select
  781.   txtValueType = strValueType
  782.   vntByte = vntReturn(1)
  783.   For lngI = LBound(vntByte) To UBound(vntByte)
  784.     txtValueByt = txtValueByt & vntByte(lngI) & " "
  785.   Next
  786.   txtValueDbl = vntReturn(2)
  787.   cmdSetValue.Enabled = True
  788.   cmdDeleteValue.Enabled = True
  789. End Sub
  790.