home *** CD-ROM | disk | FTP | other *** search
Wrap
VERSION 4.00 Begin VB.Form Form1 Caption = "RegiCon Test" ClientHeight = 4230 ClientLeft = 2265 ClientTop = 3045 ClientWidth = 7365 Height = 4635 Left = 2205 LinkTopic = "Form1" LockControls = -1 'True ScaleHeight = 4230 ScaleWidth = 7365 Top = 2700 Width = 7485 Begin VB.CommandButton cmdIsKey Caption = "Does Key Exist?" Height = 375 Left = 5400 TabIndex = 27 Top = 840 Width = 1815 End Begin VB.CommandButton cmdExit Caption = "Exit" Height = 375 Left = 5400 TabIndex = 17 Top = 3240 Width = 1815 End Begin VB.CommandButton cmdIsItem Caption = "Does Item Exist?" Height = 375 Left = 5400 TabIndex = 16 Top = 2760 Width = 1815 End Begin VB.CommandButton cmdDeleteKeyItem Caption = "Delete Item" Height = 375 Left = 5400 TabIndex = 15 Top = 2400 Width = 1815 End Begin VB.CommandButton cmdGetKeyItem Caption = "Get Item" Height = 375 Left = 5400 TabIndex = 14 Top = 2040 Width = 1815 End Begin VB.CommandButton cmdSetKeyItem Caption = "Set Item" Height = 375 Left = 5400 TabIndex = 13 Top = 1680 Width = 1815 End Begin VB.CommandButton cmdDeleteKey Caption = "Delete Key" Height = 375 Left = 5400 TabIndex = 12 Top = 480 Width = 1815 End Begin VB.CommandButton cmdCreateKey Caption = "Create Key" Height = 375 Left = 5400 TabIndex = 11 Top = 120 Width = 1815 End Begin VB.TextBox txtItemValue Height = 285 Left = 1200 MultiLine = -1 'True TabIndex = 10 Text = "Form1.frx":0000 Top = 3240 Width = 3975 End Begin VB.Frame Frame1 Caption = "Data Type" Height = 1215 Left = 1200 TabIndex = 9 Top = 1920 Width = 3975 Begin VB.OptionButton optType Caption = "DWord MSB" Height = 255 Index = 8 Left = 2640 TabIndex = 26 Top = 800 Width = 1215 End Begin VB.OptionButton optType Caption = "DWord LSB" Height = 255 Index = 7 Left = 2640 TabIndex = 25 Top = 520 Width = 1215 End Begin VB.OptionButton optType Caption = "Link" Height = 255 Index = 6 Left = 2640 TabIndex = 24 Top = 240 Width = 1215 End Begin VB.OptionButton optType Caption = "Not Defined" Height = 255 Index = 5 Left = 1080 TabIndex = 23 Top = 800 Width = 1455 End Begin VB.OptionButton optType Caption = "Expand String" Height = 255 Index = 4 Left = 1080 TabIndex = 22 Top = 520 Width = 1455 End Begin VB.OptionButton optType Caption = "Multi-line String" Height = 255 Index = 3 Left = 1080 TabIndex = 21 Top = 240 Width = 1455 End Begin VB.OptionButton optType Caption = "Binary" Height = 255 Index = 2 Left = 120 TabIndex = 20 Top = 800 Width = 975 End Begin VB.OptionButton optType Caption = "DWord" Height = 255 Index = 1 Left = 120 TabIndex = 19 Top = 520 Width = 975 End Begin VB.OptionButton optType Caption = "String" Height = 255 Index = 0 Left = 120 TabIndex = 18 Top = 240 Value = -1 'True Width = 975 End End Begin VB.TextBox txtItemName Height = 285 Left = 1200 TabIndex = 8 Top = 1560 Width = 3975 End Begin VB.TextBox txtSubKey Height = 285 Left = 1200 TabIndex = 7 Top = 1080 Width = 3975 End Begin VB.TextBox txtKey Height = 285 Left = 1200 TabIndex = 6 Text = "SOFTWARE\test" Top = 600 Width = 3975 End Begin VB.ComboBox cboRoot Height = 315 Left = 1200 TabIndex = 5 Top = 120 Width = 3975 End Begin RegistryControl.RegiCon RegiCon1 Left = 360 Top = 2040 _ExtentX = 847 _ExtentY = 847 End Begin VB.Label Label5 Alignment = 1 'Right Justify Caption = "Value:" Height = 255 Left = 360 TabIndex = 4 Top = 3240 Width = 735 End Begin VB.Label Label4 Alignment = 1 'Right Justify Caption = "Item:" Height = 255 Left = 120 TabIndex = 3 Top = 1560 Width = 855 End Begin VB.Label Label3 Alignment = 1 'Right Justify Caption = "Sub-Key:" Height = 255 Left = 120 TabIndex = 2 Top = 1080 Width = 975 End Begin VB.Label Label2 Alignment = 1 'Right Justify Caption = "Key:" Height = 255 Left = 240 TabIndex = 1 Top = 600 Width = 855 End Begin VB.Label Label1 Alignment = 1 'Right Justify Caption = "Root-Key:" Height = 255 Left = 120 TabIndex = 0 Top = 120 Width = 975 End Attribute VB_Name = "Form1" Attribute VB_Creatable = False Attribute VB_Exposed = False Private Sub Command3_Click() End Sub Option Explicit Private Sub cmdCreateKey_Click() If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub End If ' 'When you use the SetEntry method without 'specifying a KeyItemName, an empty key is created 'in the registry RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = "" RegiCon1.SetEntry End Sub Private Sub cmdDeleteKey_Click() If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub End If If txtSubKey.Text = "" Then MsgBox "You have chosen to delete a key directly off of a RootKey!" & vbCr & vbCrLf _ & "Although you can create keys directly off of HKEY_CLASSES_ROOT or HKEY_CURRENT_USER," & vbCrLf _ & "deleting a key from a root key is NOT normal and this sample will NOT delete this key!" & vbCr & vbCrLf _ & "Normally you should use the SubKey property to specify which portion of the multikey to delete (see the Help File)." & vbCr & vbCrLf _ , vbExclamation, "Delete Prevented By Sample!" Exit Sub Else If MsgBox("Are you sure you want to delete the subkey '" & txtSubKey.Text & "' from the key '" & txtKey.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Key") = vbNo Then Exit Sub End If End If ' 'To delete a Key and any of its subkeys and items, 'set Key to the parent key of the subkey to delete; 'set the SubKey to the key that you want to delete; ' 'To delete an entire key, do NOT specify a KeyItemName, otherwise 'the control will only delete the item RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.SubKey = txtSubKey.Text RegiCon1.KeyItemName = "" RegiCon1.DeleteEntry txtSubKey.Text = "" txtItemValue.Text = "" End Sub Private Sub cmdDeleteKeyItem_Click() If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub ElseIf Trim$(txtItemName) = "" Then MsgBox "Must specify an Item", vbInformation, "No Item" Exit Sub End If If MsgBox("Are you sure you want to delete the item '" & txtItemName.Text & "'?", vbQuestion + vbYesNo + vbDefaultButton2, "Delete Item") = vbNo Then Exit Sub End If 'to delete an item from a key, specify 'the key and set the KeyItemName to the item 'that you want to delete RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = txtItemName.Text RegiCon1.DeleteEntry txtItemName.Text = "" txtItemValue.Text = "" End Sub Private Sub cmdExit_Click() Unload Me End Sub Private Sub cmdGetKeyItem_Click() Dim str As String Dim i As Integer txtItemValue.Text = "" If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub ElseIf Trim$(txtItemName) = "" Then MsgBox "Must specify an Item", vbInformation, "No Item" Exit Sub End If ' 'to retrieve an item, specify the 'Key and KeyItemName, then call the 'GetEntry method. The KeyItemType and 'KeyItemValue properties will contain the 'data type and value, respectively. ' 'If unable to open/locate the item, the type 'will be REG_NONE and the value will be null RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = txtItemName.Text RegiCon1.GetEntry str = "Value: " & CStr(RegiCon1.KeyItemValue) & vbCr & vbCrLf i = RegiCon1.KeyItemType Select Case i Case dtREG_SZ str = str & "Type: REG_SZ" optType(0).Value = True Case dtREG_DWORD str = str & "Type: REG_DWORD" optType(1).Value = True Case dtREG_BINARY str = str & "Type: REG_BINARY" optType(2).Value = True Case dtREG_MULTI_SZ str = str & "Type: REG_MULTI_SZ" optType(3).Value = True Case dtREG_EXPAND_SZ str = str & "Type: REG_EXPAND_SZ" optType(4).Value = True Case dtREG_NONE str = str & "Type: REG_NONE" optType(5).Value = True Case dtREG_LINK str = str & "Type: REG_LINK" optType(6).Value = True Case dtREG_DWORD_LITTLE_ENDIAN 'this will never happen because REG_DWORD_LITTLE_ENDIAN 'and DWord are the same thing. str = str & "Type: REG_DWORD_LITTLE_ENDIAN" optType(7).Value = True Case dtREG_DWORD_BIG_ENDIAN str = str & "Type: REG_DWORD_BIG_ENDIAN" optType(8).Value = True Case Else 'list is not implemented str = str & "Type: Other (" & CStr(i) & ")" optType(5).Value = True End Select txtItemValue.Text = CStr(RegiCon1.KeyItemValue) MsgBox str End Sub Private Sub cmdIsItem_Click() If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub ElseIf Trim$(txtItemName) = "" Then MsgBox "Must specify an Item", vbInformation, "No Item" Exit Sub End If RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = txtItemName.Text If (RegiCon1.IsEntry) Then MsgBox "This IS an Item:" & vbCr & vbCrLf & "Key = " & txtKey.Text & vbCrLf & "Item = " & txtItemName Else MsgBox "This IS NOT an Item:" & vbCr & vbCrLf & "Key = " & txtKey.Text & vbCrLf & "Item = " & txtItemName End If End Sub Private Sub cmdIsKey_Click() If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub End If RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = "" If (RegiCon1.IsEntry) Then MsgBox "This IS an entry:" & vbCr & vbCrLf & "Key = " & txtKey.Text Else MsgBox "This IS NOT an entry:" & vbCr & vbCrLf & "Key = " & txtKey.Text End If End Sub Private Sub cmdSetKeyItem_Click() ' 'To set a key item, call the SetEntry 'method after specifying a Key, KeyItemName, 'KeyItemType and appropriate KeyItemValue If Trim$(txtKey.Text) = "" Then MsgBox "Must specify a Key", vbInformation, "No Key" Exit Sub ElseIf Trim$(txtItemName) = "" Then MsgBox "Must specify an Item", vbInformation, "No Item" Exit Sub End If RegiCon1.RootKey = cboRoot.ListIndex RegiCon1.Key = txtKey.Text RegiCon1.KeyItemName = txtItemName.Text RegiCon1.KeyItemValue = txtItemValue.Text RegiCon1.SetEntry End Sub Private Sub Form_Load() Dim TempString As String cboRoot.AddItem "HKEY_LOCAL_MACHINE", 0 cboRoot.AddItem "HKEY_CURRENT_USER", 1 cboRoot.AddItem "HKEY_CURRENT_CONFIG", 2 cboRoot.AddItem "HKEY_USERS", 3 cboRoot.AddItem "HKEY_CLASSES_ROOT", 4 cboRoot.AddItem "HKEY_DYN_DATA", 5 cboRoot.ListIndex = 0 RegiCon1.KeyItemType = 0 Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2 TempString = "The following sample demonstrates the Mabry RegiCon OCX." & vbCr & vbCrLf & _ "When using this sample, you have direct access to your system registry " & _ "and you can add, delete, and change the contents of your current registry settings. " & vbCr & vbCrLf & _ "You are STRONGLY encouraged to use this sample application " & _ "to create some TEST keys and items, then edit and delete the test entries." & vbCr & vbCrLf & _ "Further, a thorough understanding of the how the Key and SubKey properties work together to delete " & _ "keys is highly recommended." MsgBox TempString, vbInformation, "READ ME!" End Sub Private Sub optType_Click(Index As Integer) Static i As Integer If i = Index Then Exit Sub End If If Index = 2 Or Index = 3 Then txtItemValue.Height = 885 Else txtItemValue.Height = 285 End If RegiCon1.KeyItemType = Index i = Index txtItemValue.Text = "" End Sub