您现在的位置: 中国男护士网 >> 考试频道 >> 计算机等级 >> 二级辅导 >> VB >> 辅导 >> 正文    
  VB辅导:取得网卡序列号 【注册男护士专用博客】          

VB辅导:取得网卡序列号

www.nanhushi.com     佚名   不详 

  很多软件以取得网卡地址作为license验证,这不失为一个验证合法用户的好办法,不过要付出回复用户电话、传真的代价哦 

  将下面这段代码拷贝到程序中,然后在你的程序需要的时候调用ethernetaddress(0),该函数返回的字符串就是您机器上网卡的以太序列号。 
  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 

   ncb_retcode as byte 

   ncb_lsn as byte 

   ncb_num as byte 

   ncb_buffer as long 

   ncb_length as integer 

   ncb_callname as string * ncbnamsz 

   ncb_name as string * ncbnamsz 

   ncb_rto as byte 

   ncb_sto as byte 

   ncb_post as long 

   ncb_lana_num as byte 

   ncb_cmd_cplt as byte 

   ncb_reserve(9) as byte ’’ reserved, must be 0 

   ncb_event as long 

  end type 



  private type adapter_status 

   adapter_address(5) as byte 

   rev_major as byte 

   reserved0 as byte 

   adapter_type as byte 

   rev_minor as byte 

   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 

  private function ethernetaddress(lananumber as long) _

  as string 

   dim udtncb    as ncb 

   dim bytresponse as byte 

   dim udtastat   as astat 

   dim udttempastat as astat 

   dim lngastat   as long 

   dim strout    as string 

   dim x      as integer 

   udtncb.ncb_command = ncbreset 

   bytresponse = netbios(udtncb) 

   udtncb.ncb_command = ncbastat 

   udtncb.ncb_lana_num = lananumber
 
   udtncb.ncb_callname = "* " 

   udtncb.ncb_length = len(udtastat) 

   lngastat = heapalloc(getprocessheap(), _

  heap_generate_exceptions or heap_zero_memory, udtncb.ncb_length) 

   strout = "" 

   if lngastat then 

    udtncb.ncb_buffer = lngastat 

    bytresponse = netbios(udtncb) 

    copymemory udtastat, udtncb.ncb_buffer, len(udtastat) 

     with udtastat.adapt 

     for x = 0 to 5 

      strout = strout & right$("00" & hex$(.adapter_address(x)), 2) 

     next x 

    end with 

    heapfree getprocessheap(), 0, lngastat 

   end if 

   ethernetaddress = strout 

  end function

 

文章录入:杜斌    责任编辑:杜斌 
  • 上一篇文章:

  • 下一篇文章:
  • 【字体: 】【发表评论】【加入收藏】【告诉好友】【打印此文】【关闭窗口
     

    联 系 信 息
    QQ:88236621
    电话:15853773350
    E-Mail:malenurse@163.com
    免费发布招聘信息
    做中国最专业男护士门户网站
    最 新 热 门
    最 新 推 荐
    相 关 文 章
    没有相关文章
    专 题 栏 目

      网友评论:(只显示最新10条。评论内容只代表网友观点,与本站立场无关!)                            【进男护士社区逛逛】
    姓 名:
    * 游客填写  ·注册用户 ·忘记密码
    主 页:

    评 分:
    1分 2分 3分 4分 5分
    评论内容:
  • 请遵守《互联网电子公告服务管理规定》及中华人民共和国其他各项有关法律法规。
  • 严禁发表危害国家安全、损害国家利益、破坏民族团结、破坏国家宗教政策、破坏社会稳定、侮辱、诽谤、教唆、淫秽等内容的评论 。
  • 用户需对自己在使用本站服务过程中的行为承担法律责任(直接或间接导致的)。
  • 本站管理员有权保留或删除评论内容。
  • 评论内容只代表网友个人观点,与本网站立场无关。