自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

概括VB.NET獲取網(wǎng)卡地址的步驟

開(kāi)發(fā) 后端
這里介紹VB.NET獲取網(wǎng)卡地址,包括在Visual Basic生成標(biāo)準(zhǔn)的EXE文件、在Form1中添加一命令按鈕,缺省名為Command1等

VB.NET還是比較常用的,于是我研究了一下VB.NET獲取網(wǎng)卡地址,在這里拿出來(lái)和大家分享一下,希望對(duì)大家有用。

程序語(yǔ)言:Microsoft Visual Basic 4.0,5.0,6.0
運(yùn)行平臺(tái):WINDOWS
功能描述:IPX和NETBIOS接口需要網(wǎng)絡(luò)地址。該文通過(guò)詳細(xì)的步驟演示了如何通過(guò)VB.NET獲取網(wǎng)卡地址。

VB.NET獲取網(wǎng)卡地址步驟:

1.在Visual Basic生成標(biāo)準(zhǔn)的EXE文件。缺省創(chuàng)建 Form1.

2.在Form1中添加一命令按鈕,缺省名為Command1.

3.把下列代碼放到Form1中說(shuō)明部分。

  1. Option Explicit   
  2. Private Const NCBASTAT = &H33   
  3. Private Const NCBNAMSZ = 16   
  4. Private Const HEAP_ZERO_MEMORY = &H8   
  5. Private Const HEAP_GENERATE_EXCEPTIONS = &H4   
  6. Private Const NCBRESET = &H32   
  7. Private Type NCB   
  8. ncb_command As Byte 'Integer   
  9. ncb_retcode As Byte 'Integer   
  10. ncb_lsn As Byte 'Integer   
  11. ncb_num As Byte ' Integer   
  12. ncb_buffer As Long 'String   
  13. ncb_length As Integer   
  14. ncb_callname As String * NCBNAMSZ   
  15. ncb_name As String * NCBNAMSZ   
  16. ncb_rto As Byte 'Integer   
  17. ncb_sto As Byte ' Integer   
  18. ncb_post As Long   
  19. ncb_lana_num As Byte 'Integer   
  20. ncb_cmd_cplt As Byte 'Integer   
  21. ncb_reserve(9) As Byte ' Reserved, must be 0   
  22. ncb_event As Long   
  23. End Type  
  24.  
  25. Private Type ADAPTER_STATUS   
  26. adapter_address(5) As Byte 'As String * 6   
  27. rev_major As Byte 'Integer   
  28. reserved0 As Byte 'Integer   
  29. adapter_type As Byte 'Integer   
  30. rev_minor As Byte 'Integer   
  31. duration As Integer   
  32. frmr_recv As Integer   
  33. frmr_xmit As Integer   
  34. iframe_recv_err As Integer   
  35. xmit_aborts As Integer   
  36. xmit_success As Long   
  37. recv_success As Long   
  38. iframe_xmit_err As Integer   
  39. recv_buff_unavail As Integer   
  40. t1_timeouts As Integer   
  41. ti_timeouts As Integer   
  42. Reserved1 As Long   
  43. free_ncbs As Integer   
  44. max_cfg_ncbs As Integer   
  45. max_ncbs As Integer   
  46. xmit_buf_unavail As Integer   
  47. max_dgram_size As Integer   
  48. pending_sess As Integer   
  49. max_cfg_sess As Integer   
  50. max_sess As Integer   
  51. max_sess_pkt_size As Integer   
  52. name_count As Integer   
  53. End Type   
  54.  
  55. Private Type NAME_BUFFER   
  56. name As String * NCBNAMSZ   
  57. name_num As Integer   
  58. name_flags As Integer   
  59. End Type  
  60.  
  61. Private Type ASTAT   
  62. adapt As ADAPTER_STATUS   
  63. NameBuff(30) As NAME_BUFFER   
  64. End Type   
  65.  
  66. Private Declare Function Netbios Lib "netapi32.dll" (pncb As NCB) As Byte   
  67. Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" _  
  68. (hpvDest As Any, ByVal hpvSource As Long, ByVal cbCopy As Long)   
  69. Private Declare Function GetProcessHeap Lib "kernel32" () As Long   
  70. Private Declare Function HeapAlloc Lib "kernel32" _   
  71. (ByVal hHeap As Long, ByVal dwFlags As Long, _   
  72. ByVal dwBytes As Long) As Long   
  73. Private Declare Function HeapFree Lib "kernel32" (ByVal hHeap As Long,_   
  74. ByVal dwFlags As Long, lpMem As Any) As Long 

把下面的代碼放入Command1_Click的事件中:

  1. Private Sub Command1_Click()   
  2. Dim myNcb As NCB   
  3. Dim bRet As Byte   
  4. myNcb.ncb_command = NCBRESET   
  5. bRet = Netbios(myNcb)   
  6. myNcb.ncb_command = NCBASTAT   
  7. myNcb.ncb_lana_num = 0   
  8. myNcb.ncb_callname = "* "   
  9. Dim myASTAT As ASTAT, tempASTAT As ASTAT   
  10. Dim pASTAT As Long   
  11. myNcb.ncb_length = Len(myASTAT)   
  12. Debug.Print Err.LastDllError   
  13. pASTAT = HeapAlloc(GetProcessHeap(), HEAP_GENERATE_EXCEPTIONS _   
  14. Or HEAP_ZERO_MEMORY, myNcb.ncb_length)   
  15. If pASTAT = 0 Then   
  16. Debug.Print "memory allcoation failed!"   
  17. Exit Sub   
  18. End If  
  19.  
  20. myNcb.ncb_buffer = pASTAT   
  21. bRet = Netbios(myNcb)   
  22. Debug.Print Err.LastDllError   
  23. CopyMemory myASTAT, myNcb.ncb_buffer, Len(myASTAT)   
  24. MsgBox Hex(myASTAT.adapt.adapter_address(0)) & " " & _   
  25. Hex(myASTAT.adapt.adapter_address(1)) _   
  26. & " " & Hex(myASTAT.adapt.adapter_address(2)) & " " _   
  27. & Hex(myASTAT.adapt.adapter_address(3)) _   
  28. & " " & Hex(myASTAT.adapt.adapter_address(4)) & " " _   
  29. & Hex(myASTAT.adapt.adapter_address(5))   
  30. HeapFree GetProcessHeap(), 0, pASTAT   
  31. End Sub  

4.按F5,運(yùn)行該程序。

5.點(diǎn)擊Command1。注意,VB.NET獲取網(wǎng)卡地址將在一信息框中顯示出來(lái)。

【編輯推薦】

  1. 概述VB.NET Option Strict
  2. 詳細(xì)描述VB.NET PadLeft方法
  3. 簡(jiǎn)單分析VB.NET臨時(shí)文件
  4. 概括VB.NET日期類(lèi)型的值運(yùn)算
  5. 淺析VB.NET Imports語(yǔ)句
責(zé)任編輯:佚名 來(lái)源: 博客園
相關(guān)推薦

2010-01-14 17:03:01

VB.NET獲取網(wǎng)卡地

2009-10-14 10:19:57

VB.NET Doma

2009-10-15 17:50:48

VB.NET Spli

2009-10-26 15:57:07

VB.NET使用Ora

2009-10-13 14:50:59

VB.NET Envi

2009-10-14 14:04:29

VB.NET創(chuàng)建Web

2009-10-14 16:46:25

VB.NET OnSt

2009-11-03 10:51:33

VB.NET共享

2009-10-21 10:05:30

VB.NET運(yùn)行環(huán)境

2009-10-23 14:06:07

VB.NET類(lèi)對(duì)象

2009-10-27 11:32:42

VB.NET Disp

2009-10-14 13:15:09

VB.NET數(shù)據(jù)綁定

2009-11-03 10:00:20

VB.NET New方

2009-10-14 15:34:29

VB.NET窗體編程模

2009-10-28 10:51:32

VB.NET默認(rèn)屬性

2009-10-15 17:33:45

VB.NET日期類(lèi)型

2009-10-30 10:19:43

VB.NET OBEX

2009-11-02 17:49:05

VB.NET抽象類(lèi)

2009-10-29 16:23:42

VB.NET實(shí)現(xiàn)IEn

2009-11-02 09:21:04

VB.NET文件系統(tǒng)
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)