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 Integer
        ncb_retcode As Integer
        ncb_lsn As Integer
        ncb_num As 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 Declare Function Netbios Lib "netapi32.dll" _
          (pncb As NCB) As BytePrivate Sub Form_Load()
NC = Space(30)
Text1.Text = Netbios(NC.ncb_num)'不知是不是这样调用?
End Sub

解决方案 »

  1.   

    你看看下面的程序,它用来得到网卡地址:
    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
      

  2.   

    to dingming(丁叮) :谢谢!
    我运行了,但又提示dim udtastat   as astat 未定义。
    我用我的那个出了个结果是3,不知为何物??