我用api函数写了一个操作注册表设置代理服务器的程序,不知怎么的不起作用,我的系统是winxp,高人帮忙看看
'---------------------------------------------------------------
'- 注册表 API 声明...
'---------------------------------------------------------------
Dim hKey As Long
Dim lpSubKey As String
Dim lpReserved As Long
Dim lpType As Long
Dim lpData As String
Dim lpcbData As Long
Dim phkResult As Long
Dim ReturnCode As Long
Dim SQL_Driver As String
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
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 RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Command77_Click()
lpReserved = 0&
hKey = HKEY_CURRENT_USER
lpSubKey = "Software\Microsoft\Windows\CurrentVersion\Internet Settings"
ReturnCode = RegOpenKeyEx(hKey, lpSubKey, lpReserved, KEY_ALL_ACCESS, phkResult)
MsgBox (ReturnCode)
If ReturnCode <> ERROR_SUCCESS Then GoTo DSNERR
lpType = REG_BINARY
lpData = 1&
lpcbData = 8
ReturnCode = RegSetValueEx(phkResult, "ProxyEnable", lpReserved, lpType, ByVal lpData, lpcbData)
If ReturnCode <> ERROR_SUCCESS Then GoTo DSNERR
lpType = REG_SZ
lpData = "202.109.126.27:80"
lpcbData = Len(lpData)
ReturnCode = RegSetValueEx(phkResult, "ProxyServer", lpReserved, lpType, ByVal lpData, lpcbData)
If ReturnCode <> ERROR_SUCCESS Then GoTo DSNERR
RegCloseKey (phkResult)
DSNERR: RegCloseKey (phkResult)
End Sub