欢迎光临
我们一直在努力

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

建站超值云服务器,限时71元/月

将程序生成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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 将你的网站设置为客户的信任站点–VB方案
分享到: 更多 (0)

相关推荐

  • 暂无文章