首页 | 麦客学吧 | 视频教程 | FLASH小游戏 | 素材下载 | 常用工具
您当前的位置:首页 > 程序开发 > ASP > 正文

Asp结合网卡绑定来限制他人非法登录

出处:麦客学吧 [2008-3-6 8:52:20] 作者:lijun355 点击数:383

讨论交流:http://x8.maicoo.com/team/11158.html

===================================================
'可以将代码修改一下,做一个ActiveX Dll,然后在服务器端
'注册,调用即可得到MAC地址.
'VB版中有一个相应的组件代码
'===================================================

   Option Explicit

   Private Const NCBASTAT = &H33
   Private Const NCBNAMSZ = 16
   Private Const HEAP_ZERO_MEMORY = &H8
   Private Const HEAP_GENERATE_EXCEPTIONS = &H4
   Private Const NCBRESET = &H32

   Private Type NCB
        ncb_command As Byte 'Integer
        ncb_retcode As Byte 'Integer
        ncb_lsn As Byte 'Integer
        ncb_num As Byte ' Integer
        ncb_buffer As Long 'String
        ncb_length As Integer
        ncb_callname As String * NCBNAMSZ
        ncb_name As String * NCBNAMSZ
        ncb_rto As Byte 'Integer
        ncb_sto As Byte ' Integer
        ncb_post As Long
        ncb_lana_num As Byte 'Integer
        ncb_cmd_cplt As Byte  'Integer
        ncb_reserve(9) As Byte ' Reserved, must be 0
        ncb_event As Long
   End Type
   Private Type ADAPTER_STATUS
        adapter_address(5) As Byte 'As String * 6
        rev_major As Byte 'Integer
        reserved0 As Byte 'Integer
        adapter_type As Byte 'Integer
        rev_minor As Byte 'Integer
        duration As Integer
        frmr_recv As Integer
        frmr_xmit As Integer
        iframe_recv_err As Integer
        xmit_aborts As Integer
        xmit_success As Long
        recv_success As Long
        iframe_xmit_err As Integer
        recv_buff_unavail As Integer
        t1_timeouts As Integer
        ti_timeouts As Integer
        Reserved1 As Long
        free_ncbs As Integer
        max_cfg_ncbs As Integer
        max_ncbs As Integer
        xmit_buf_unavail As Integer
        max_dgram_size As Integer
        pending_sess As Integer
        max_cfg_sess As Integer
        max_sess As Integer
        max_sess_pkt_size As Integer
        name_count As Integer
   End Type
   Private Type NAME_BUFFER
        name  As String * NCBNAMSZ
        name_num As Integer
        name_flags As Integer
   End Type
   Private Type ASTAT
        adapt As ADAPTER_STATUS
        NameBuff(30) As NAME_BUFFER
   End Type

   Private Declare Function Netbios Lib "netapi32.dll" _
           (pncb As NCB) As Byte
   Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" ( _
           hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)
   Private Declare Function GetProcessHeap Lib "kernel32" () As Long
   Private Declare Function HeapAlloc Lib "kernel32" _
           (ByVal hHeap As Long, ByVal dwFlags As Long, _
           ByVal dwBytes As Long) As Long
   Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long, _
           ByVal dwFlags As Long, lpMem As Any) As Long

Public Function GetMACAddress(sIP As String) As String
    Dim sRtn As String
    Dim myNcb As NCB
    Dim bRet As Byte
    
    Dim aIP() As String
    Dim X As Long
    Dim nIP As String
    
    If InStr(sIP, ".") = 0 Then
       GetMACAddress = "Invaild IP Address."
       Exit Function
    End If
    
    aIP = Split(sIP, ".", -1, vbTextCompare)
    If UBound(aIP()) <> 3 Then
       GetMACAddress = "Invaild IP Address."
       Exit Function
    End If
    
    For X = 0 To UBound(aIP())
        If Len(aIP(X)) > 3 Then
           GetMACAddress = "Invaild IP Address"
           Exit Function
        End If
        
        If IsNumeric(aIP(X)) = False Then
           GetMACAddress = "Invaild IP Address"
           Exit Function
        End If
        
        If InStr(aIP(X), ",") <> 0 Then
           GetMACAddress = "Invaild IP Address"
           Exit Function
        End If
        
        If CLng(aIP(X)) > 255 Then
           GetMACAddress = "Invaild IP Address"
           Exit Function
        End If
        
        If nIP = "" Then
           nIP = String(3 - Len(aIP(X)), "0") & aIP(X)
        Else
<scr

【责任编辑: lanier

素材中心
麦客酷站赏析频道

精彩图文推荐

关于本站 - 联系站长 - 广告服务 - 合作伙伴 - 网站地图 - 版权声明 - 报告错误 - 收藏本站 | Http://www.MaiCoo.com

Copyright © 2005 - 2008 MaiCoo.com All Rights Reserved

违法和不良信息举报中心 本站服务器空间和带宽由雷克斯网络提供赞助
浙ICP备06017818号