⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 51.htm

📁 VB的一些网络编程的例子,个人认为还不错。大家一起来研究一下.
💻 HTM
字号:
<p>取得网卡序列号   </p>
<p></p>
<p>  很多软件以取得网卡地址作为License验证,这不失为一个验证合法用户的好办法,不过要付出回复用户电话、传真的代价哦 ^_^ </p>
<p>  将下面这段代码拷贝到程序中,然后在你的程序需要的时候调用EthernetAddress(0),该函数返回的字符串就是您机器上网卡的以太序列号。 </p>
<p></p>
<p>Private Const NCBASTAT = &H33 </p>
<p>Private Const NCBNAMSZ = 16 </p>
<p>Private Const HEAP_ZERO_MEMORY = &H8 </p>
<p>Private Const HEAP_GENERATE_EXCEPTIONS = &H4 </p>
<p>Private Const NCBRESET = &H32 </p>
<p></p>
<p>Private Type NCB </p>
<p> ncb_command As Byte </p>
<p> ncb_retcode As Byte </p>
<p> ncb_lsn As Byte </p>
<p> ncb_num As Byte </p>
<p> ncb_buffer As Long </p>
<p> ncb_length As Integer </p>
<p> ncb_callname As String * NCBNAMSZ </p>
<p> ncb_name As String * NCBNAMSZ </p>
<p> ncb_rto As Byte </p>
<p> ncb_sto As Byte </p>
<p> ncb_post As Long </p>
<p> ncb_lana_num As Byte </p>
<p> ncb_cmd_cplt As Byte </p>
<p> ncb_reserve(9) As Byte ' Reserved, must be 0 </p>
<p> ncb_event As Long </p>
<p>End Type </p>
<p></p>
<p>Private Type ADAPTER_STATUS </p>
<p> adapter_address(5) As Byte </p>
<p> rev_major As Byte </p>
<p> reserved0 As Byte </p>
<p> adapter_type As Byte </p>
<p> rev_minor As Byte </p>
<p> duration As Integer </p>
<p> frmr_recv As Integer </p>
<p> frmr_xmit As Integer </p>
<p> iframe_recv_err As Integer </p>
<p> xmit_aborts As Integer </p>
<p> xmit_success As Long </p>
<p> recv_success As Long </p>
<p> iframe_xmit_err As Integer </p>
<p> recv_buff_unavail As Integer </p>
<p> t1_timeouts As Integer </p>
<p> ti_timeouts As Integer </p>
<p> Reserved1 As Long </p>
<p> free_ncbs As Integer </p>
<p> max_cfg_ncbs As Integer </p>
<p> max_ncbs As Integer </p>
<p> xmit_buf_unavail As Integer </p>
<p> max_dgram_size As Integer </p>
<p> pending_sess As Integer </p>
<p> max_cfg_sess As Integer </p>
<p> max_sess As Integer </p>
<p> max_sess_pkt_size As Integer </p>
<p> name_count As Integer </p>
<p>End Type </p>
<p></p>
<p>Private Type NAME_BUFFER </p>
<p> name As String * NCBNAMSZ </p>
<p> name_num As Integer </p>
<p> name_flags As Integer </p>
<p>End Type </p>
<p></p>
<p>Private Type ASTAT </p>
<p> adapt As ADAPTER_STATUS </p>
<p> NameBuff(30) As NAME_BUFFER </p>
<p>End Type </p>
<p></p>
<p>Private Declare Function Netbios Lib "netapi32.dll" _</p>
<p>(pncb As NCB) As Byte </p>
<p></p>
<p>Private Declare Sub CopyMemory Lib "kernel32" Alias _</p>
<p>"RtlMoveMemory" (hpvDest As Any, ByVal hpvSource As Long, _</p>
<p>ByVal cbCopy As Long) </p>
<p></p>
<p>Private Declare Function GetProcessHeap Lib "kernel32" () _</p>
<p>As Long </p>
<p></p>
<p>Private Declare Function HeapAlloc Lib "kernel32" _</p>
<p>(ByVal hHeap As Long, ByVal dwFlags As Long, _</p>
<p>ByVal dwBytes As Long) As Long </p>
<p></p>
<p>Private Declare Function HeapFree Lib "kernel32" _</p>
<p>(ByVal hHeap As Long, ByVal dwFlags As Long, lpMem As Any) _</p>
<p>As Long </p>
<p></p>
<p>Private Function EthernetAddress(LanaNumber As Long) _</p>
<p>As String </p>
<p></p>
<p> Dim udtNCB    As NCB </p>
<p> Dim bytResponse As Byte </p>
<p> Dim udtASTAT   As ASTAT </p>
<p> Dim udtTempASTAT As ASTAT </p>
<p> Dim lngASTAT   As Long </p>
<p> Dim strOut    As String </p>
<p> Dim x      As Integer </p>
<p></p>
<p> udtNCB.ncb_command = NCBRESET </p>
<p> bytResponse = Netbios(udtNCB) </p>
<p> udtNCB.ncb_command = NCBASTAT </p>
<p> udtNCB.ncb_lana_num = LanaNumber </p>
<p> udtNCB.ncb_callname = "* " </p>
<p> udtNCB.ncb_length = Len(udtASTAT) </p>
<p> lngASTAT = HeapAlloc(GetProcessHeap(), _</p>
<p>HEAP_GENERATE_EXCEPTIONS Or HEAP_ZERO_MEMORY, udtNCB.ncb_length) </p>
<p></p>
<p> strOut = "" </p>
<p> If lngASTAT Then </p>
<p>  udtNCB.ncb_buffer = lngASTAT </p>
<p>  bytResponse = Netbios(udtNCB) </p>
<p>  CopyMemory udtASTAT, udtNCB.ncb_buffer, Len(udtASTAT) </p>
<p>   With udtASTAT.adapt </p>
<p>   For x = 0 To 5 </p>
<p>    strOut = strOut & Right$("00" & Hex$(.adapter_address(x)), 2) </p>
<p>   Next x </p>
<p>  End With </p>
<p>  HeapFree GetProcessHeap(), 0, lngASTAT </p>
<p> End If </p>
<p> EthernetAddress = strOut </p>
<p>End Function  </p>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -