您的位置:首页网页设计ASP实例 → 将你的网站设置为客户的信任站点--VB方案

将你的网站设置为客户的信任站点--VB方案

时间:2004/11/7 3:00:00来源:本站整理作者:蓝点我要评论(0)

发布于:2002-1-1

将程序生成EXE,文件名即为你的网站名称



Const HKEY_CLASSES_ROOT = -2147483648#

Const HKEY_CURRENT_USER = -2147483647#

Const HKEY_LOCAL_MACHINE = -2147483646#

Const HKEY_USERS = -2147483645#





Const REG_SZ = 1& '字符串值

Const REG_BINARY = 3& '二?制值

Const REG_DWORD = 4& 'DWORD 值





Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, ByRef phkResult As Long) As Long



Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey 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 Form_Load()

Call SetTrustedSite(App.EXEName)

Unload Me

End Sub



'//Set Trust site

Private Function SetTrustedSite(ByVal StrSiteName As String)

On Error GoTo Errhandle

Dim nKeyHandle, KeyValue, Iresult As Long

Dim StrkeyPath As String

StrkeyPath = "Software\Microsoft\Windows\CurrentVersion\Internet Settings\ZoneMap\Domains\"

StrkeyPath = StrkeyPath & SplitSiteName(StrSiteName)

KeyValue = 2

Call RegCreateKey(HKEY_CURRENT_USER, StrkeyPath, nKeyHandle)

Iresult = RegSetValueEx(nKeyHandle, "http", 0, REG_DWORD, KeyValue, 4)

If Iresult = 0 Then

MsgBox "You have accept http://" & StrSiteName & " as your Trusted Site!"

Else

MsgBox "Fail add http://" & StrSiteName & " as your Trusted Site!"

End If

Call RegCloseKey(nKeyHandle)

Exit Function

Errhandle:

MsgBox "Fail add http://" & StrSiteName & " as your Trusted Site!"

End Function



'// Split SiteName

'// "A.B.C.D.E" ----> "D.E/A.B.C"

'// "A.B.C.D" ----> "C.D/A.B"

'// "A.B.C" ----> "B.C/A"

'// "A.B" ----> "A.B"

'// "A" ----> "A"

Private Function SplitSiteName(ByVal StrSiteName As String) As String

Dim ArraySiteName

Dim IntArrayLen, I As Integer

Dim StrSplitSite As String



ArraySiteName = Split(StrSiteName, ".")

IntArrayLen = UBound(ArraySiteName)



If IntArrayLen > 1 Then

StrSplitSite = ArraySiteName(IntArrayLen - 1) & "." & ArraySiteName(IntArrayLen) & "\"

For I = 0 To IntArrayLen - 2

If I = 0 Then

StrSplitSite = StrSplitSite & ArraySiteName(I)

Else

StrSplitSite = StrSplitSite & "." & ArraySiteName(I)

End If

Next

SplitSiteName = StrSplitSite

Else

SplitSiteName = StrSiteName

End If



End Function


相关阅读 Mac和Windows哪个好 windows和mac os对比介绍Win10预览版怎么升级 Win10预览版升级方法厂商不再预装Win7或8.1系统,驱动人生帮您快速升级Mac移动硬盘安装win8 Mac将win装在移动硬盘使用教程windows10xboxone串流简单教程Windows Hello怎么用 Windows Hello使用设置教程win10怎么关闭自动更新 win10如何关闭自动更新Mac系统如何远程桌面到Windows系统

文章评论
发表评论

热门文章 没有查询到任何记录。

最新文章 迅雷新手完全入门手册 asp下面javascript上传图片限制格式大小方法告诉大家网页弹出窗口应用总结ASP常见错误类型大全asp常见错误分析和解决办法

人气排行 总是弹出visual studio 实时调试器 三种解决SQLSERVER存储过程及调用详解Asp获取真实IP地址ASP中连接Mssql的几种方法一个简单好用的UBB编辑器(含代码)如何用Split将字符串转换为数组并获取数组下ASP防止表单重复提交的办法告诉你免费的简单聊天室源代码