当前位置: 移动技术网 > IT编程>开发语言>.net > 将你的网站设置为客户的信任站点--VB方案

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

2018年10月13日  | 移动技术网IT编程  | 我要评论
发布于: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 = "softwaremicrosoftwindowscurrentversioninternet settingsonemapdomains"
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 https://" & strsitename & " as your trusted site!"
else
msgbox "fail add https://" & strsitename & " as your trusted site!"
end if
call regclosekey(nkeyhandle)
exit function
errhandle:
msgbox "fail add https://" & 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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网