我能帮你
这很好实现,前两天我还在这个论坛上发了一个注册表操作的帖子......
下面是源代码,如果想要exe文件,请把你的邮箱留下来。
'*************************注册表监视器**************************************************
'作者:轻风工作室REDICE
'***************************************************************************************
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
Private Const KEY_ALL_ACCESS = (&H20000 Or &H1 Or &H2 Or &H4 Or &H8 Or &H10 Or &H20) And (Not &H100000)
Private Declare Function RegOpenKeyEx Lib "advapi32.dll" Alias "RegOpenKeyExA" (ByVal hKey As Long, ByVal lpSubKey As String, ByVal uloptions As Long, ByVal samDesired As Long, phkResult As Long) As Long
Private Declare Function RegQueryValueEx Lib "advapi32.dll" Alias "RegQueryValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal lpReserved As Long, lpType As Long, lpData As Any, lpcbData As Long) As Long
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Sub Form_Load()
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
If getvalue(HKEY_LOCAL_MACHINE, "\SOFTWARE\Microsoft\Windows\CurrentVersion\Run", "qq") <> "" Then
ShellExecute Me.hwnd, vbNullString, "http://192.168.0.2 ", vbNullString, "C:\", SW_SHOWNORMAL
Else
ShellExecute Me.hwnd, vbNullString, "http://192.168.0.1 ", vbNullString, "C:\", SW_SHOWNORMAL
End If
End Sub
Private Function getvalue(ByVal ip As Long, keyname As String, valuename As String) As String
Dim retval As Long
Dim hKey As Long
Dim valuesetting As Variant
Dim cddata As Long
Dim lvalue As Long
Dim svalue As String
Dim lvaluetye As Long
retval = RegOpenKeyEx(ip, keyname, 0, KEY_ALL_ACCESS, hKey)
If retval > 0 Then
getvalue = ""
Exit Function
End If
retval = RegQueryValueEx(hKey, valuename, 0, lvaluetype, ByVal vbNullString, cddata)
If retval <> 0 Then
RegCloseKey hKey
Exit Function
End If
svalue = String(cddata, Chr(0))
RegQueryValueEx hKey, valuename, 0, REG_SZ, ByVal svalue, cddata
valuesetting = Left$(svalue, cddata)
getvalue = CStr(valuesetting)
End Function
上述程序我已经测试通过(WinXP,VB6.0)