⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 regconnect.frm

📁 一个用java jni远程访问注册表的例子
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmTest 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "RegConnect Test"
   ClientHeight    =   4530
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   5610
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MinButton       =   0   'False
   ScaleHeight     =   4530
   ScaleWidth      =   5610
   ShowInTaskbar   =   0   'False
   StartUpPosition =   3  'Windows Default
   Begin VB.TextBox txtValue 
      Height          =   375
      Left            =   1680
      TabIndex        =   13
      ToolTipText     =   "Value to set or what was retrieved"
      Top             =   3360
      Width           =   3855
   End
   Begin VB.TextBox txtValueName 
      Height          =   375
      Left            =   1680
      TabIndex        =   11
      Text            =   "My Value"
      ToolTipText     =   "Value that you want to use"
      Top             =   2880
      Width           =   3855
   End
   Begin VB.TextBox txtKeyName 
      Height          =   375
      Left            =   1680
      TabIndex        =   9
      Text            =   "software\ibm\mykey"
      ToolTipText     =   "Key that you want to use"
      Top             =   2400
      Width           =   3855
   End
   Begin VB.TextBox txtMachineName 
      Height          =   375
      Left            =   1680
      TabIndex        =   0
      ToolTipText     =   "Name or IP address of machine you want to interrogate.  Blank for local machine"
      Top             =   120
      Width           =   3855
   End
   Begin VB.Frame Frame1 
      Caption         =   "Registry Key Root"
      Height          =   1815
      Left            =   120
      TabIndex        =   1
      Top             =   480
      Width           =   5415
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_DYN_DATA"
         Height          =   255
         Index           =   5
         Left            =   240
         TabIndex        =   7
         Top             =   1440
         Width           =   2775
      End
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_CURRENT_CONFIG"
         Height          =   255
         Index           =   4
         Left            =   240
         TabIndex        =   6
         Top             =   1200
         Width           =   2775
      End
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_USERS"
         Height          =   255
         Index           =   3
         Left            =   240
         TabIndex        =   5
         Top             =   960
         Width           =   2775
      End
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_LOCAL_MACHINE"
         Height          =   255
         Index           =   2
         Left            =   240
         TabIndex        =   4
         Top             =   720
         Value           =   -1  'True
         Width           =   2775
      End
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_CURRENT_USER"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   3
         Top             =   480
         Width           =   2775
      End
      Begin VB.OptionButton Option1 
         Caption         =   "HKEY_CLASSES_ROOT"
         Height          =   255
         Index           =   0
         Left            =   240
         TabIndex        =   2
         Top             =   240
         Width           =   2775
      End
   End
   Begin VB.CommandButton cmdGetValue 
      Caption         =   "Get Value"
      Height          =   495
      Left            =   3360
      TabIndex        =   15
      ToolTipText     =   "Get a registry value"
      Top             =   3960
      Width           =   1215
   End
   Begin VB.CommandButton cmdSetValue 
      Caption         =   "Set Value"
      Height          =   495
      Left            =   1080
      TabIndex        =   14
      ToolTipText     =   "Set a registry value"
      Top             =   3960
      Width           =   1215
   End
   Begin VB.Label Label1 
      Caption         =   "Value"
      Height          =   255
      Index           =   3
      Left            =   120
      TabIndex        =   12
      Top             =   3360
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "Value Name"
      Height          =   255
      Index           =   2
      Left            =   120
      TabIndex        =   10
      Top             =   2880
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "Key Name"
      Height          =   255
      Index           =   1
      Left            =   120
      TabIndex        =   8
      Top             =   2400
      Width           =   1455
   End
   Begin VB.Label Label1 
      Caption         =   "Machine Name"
      Height          =   255
      Index           =   0
      Left            =   120
      TabIndex        =   16
      Top             =   120
      Width           =   1455
   End
End
Attribute VB_Name = "frmTest"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdSetValue_Click()
Dim MachineName As String
Dim KeyName As String
Dim ValueName As String
Dim Value As String
Dim KeyValue As Long
Dim i As Integer

    ' Get the values of the text boxes
    MachineName = txtMachineName.Text
    KeyName = txtKeyName.Text
    ValueName = txtValueName.Text
    Value = txtValue.Text
    
    'Decide which root we are going to use
    For i = 0 To 5
        If Option1(i).Value = True Then
            KeyValue = Choose(i, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, _
                                HKEY_USERS, HKEY_CURRENT_CONFIG, HKEY_DYN_DATA)
            Exit For
        End If
    Next
    i = SetRegValue(MachineName, KeyValue, KeyName, ValueName, Value)
    MsgBox "Call returned " & Str(i), vbOKOnly, "RegConnect"
End Sub
Private Sub cmdGetValue_Click()
Dim MachineName As String
Dim KeyName As String
Dim ValueName As String
Dim Value As String
Dim KeyValue As Long
Dim i As Integer

    MachineName = txtMachineName.Text
    KeyName = txtKeyName.Text
    ValueName = txtValueName.Text
    Value = txtValue.Text
    
    For i = 0 To 5
        If Option1(i).Value = True Then
            KeyValue = Choose(i, HKEY_CLASSES_ROOT, HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE, _
                                HKEY_USERS, HKEY_CURRENT_CONFIG, HKEY_DYN_DATA)
            Exit For
        End If
    Next
    txtValue.Text = GetRegValue(MachineName, KeyValue, KeyName, ValueName)
    MsgBox "Call returned " & txtValue.Text, vbOKOnly, "RegConnect"
End Sub


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -