我用api函数写了一个操作注册表设置代理服务器的程序,不知怎么的不起作用,我的系统是winxp,高人帮忙看看

popsoft 2004-08-11 04:15:38
'---------------------------------------------------------------
'- 注册表 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
...全文
135 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
cpio 2004-08-23
  • 打赏
  • 举报
回复
没有错误提示?

就直接没有效果啊?
loverpyh 2004-08-23
  • 打赏
  • 举报
回复
ding
popsoft 2004-08-23
  • 打赏
  • 举报
回复
不是权力的问题,普通用户就是ring3权限
popsoft 2004-08-14
  • 打赏
  • 举报
回复
详细点,代码怎么写
of123 2004-08-11
  • 打赏
  • 举报
回复
权限问题。

1,486

社区成员

发帖
与我相关
我的任务
社区描述
VB API
社区管理员
  • API
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧