ҡդӶ ʵŧ 纺촨շ٨絴͵ ᷹ФѺ

͵Դҷҧ Inbox Ѻ

˹ѡ
-
VB 6/VB.Net
ASP/ASP.Net
Ѻ¤
¹ҹ Flash Movie
ռͺش  
 RSS Feeds
 ǹŴ RSS Reader ...   Download  RSS Reader

Forum - www.g2gnet.com
Webmaster - www.g2gnet.com
Visitors - Session views
 5 6 1 6 1 0 4

7 ѹҤ ..2549
58 Users On-Line.
Visitors - Page views
 8 9 7 3 8 4 7
1 Ҿѹ ..2551

Google   
g2gnet.com
Ҵѡ:  

VB6 Ѻҹ MAC Address ͧ LAN Card Ըպҹ ()

Category »  VB 6/VB.Net
: Webmaster 28/8/2552   : 02:34
(ҹ : 21934) 
¹͹ẺѴ (ʴ͹) зá VB.NET ͡ҡ͹ ͸Ժº ... ͤӶҡ椹 ҧͧѹ ҵ˹ѹաҡѹ ֧͡ VB6 ͧ¹ VB.Net ... (Դ) : ҷ ѹͧѡ ͧǤԴ Թҡ÷ͧҧҡ ͹лѹ еͧ ͷ¡ "" зӤѭ ... Ǵǧҧ֡ "ͧԧ" ͡¹͹շشѺ ... ͧ ... ѧ鹢ͧẺѹͧաþ٨ ... ҡͧͧ֡Ҵ Դ¤Ҩж١е鹵¨觡Щٴ 任ءҹҧʺ ...

ǤԴͧҹ鹹 ... API, OCX, DLL ActiveX ¤觢ͧ DOS ѺҹŨҡ Text File ҹ繾 ... ѡäԴѭẺ ö任ءҧҧҧҡ ¤Ҩҡ͹ 觵ҧͧ DOS ҡա¹ȷҧʴ (Redirect) ж繡ʴ͡ҧҾ» ҡʹͧ > ª

Դ MyIPConfig.txt
Windows IP Configuration
        Host Name . . . . . . . . . . . . : Thongkorn
        Primary Dns Suffix  . . . . . . . : 
        Node Type . . . . . . . . . . . . : Unknown
        IP Routing Enabled. . . . . . . . : No
        WINS Proxy Enabled. . . . . . . . : No

Ethernet adapter Local Area Connection:
        Connection-specific DNS Suffix  . : 
        Description . . . . . . . . . . . : Realtek RTL8139/810x Family Fast Ethernet NIC
        Physical Address. . . . . . . . . : 00-00-00-99-99-99
        Dhcp Enabled. . . . . . . . . . . : Yes
        Autoconfiguration Enabled . . . . : Yes
        IP Address. . . . . . . . . . . . : 192.168.0.151
        Subnet Mask . . . . . . . . . . . : 255.255.255.0
        Default Gateway . . . . . . . . . : 192.168.0.1
        DHCP Server . . . . . . . . . . . : 192.168.0.1
        DNS Servers . . . . . . . . . . . : 192.168.0.1
        Lease Obtained. . . . . . . . . . : Wednesday, August 26, 2009 11:03:55 PM
        Lease Expires . . . . . . . . . . : Tuesday, January 19, 2038 10:14:07 AM
ҡ ipconfig /all >> MyIPConfig.txt ¶֧ Ӣŷ仵ͷ¨ҡ (ǡѺͧͧ÷ Redirect)

ѡäԴ¹ (੾ VB6 ҹ)
  • ѹ¹͡ DOS ҹҧ Shell
  • Redirect 红 Text File
  • ҹ Text File ҷк÷Ѵ Ҩ
  • Ҥ Physical Address
      Physical Address. . . . . . . . . : 00-00-00-99-99-99
  • ͢ŷͧ
    • Ѵͧҧ˹ ѧ͡ ( TRIM)
    • ѺŨҡҧ 17 MAC Address 12 ͧ - ա 5
    ǹŴ
    ǹŴ Source Code Ѻ MS Visual Basic 6.0 - Service Pack 6
     ǹŴ Visual Basic 6.0 SP5: Run-Time Redistribution Pack
     ǹŴ Microsoft Data Access Object (MDAC) Jet 4.0 Update
     ǹŴ Microsoft Visual Basic Service Pack 6

    CMD Command - ëͿ
    觵ҧͧ DOS
    ¹ MAC Address (Media Access Control Address) Ẻ
    ҧͷԴͤҵͧ
  • ͡Ẻ (Design - Time)
  • RUN TIME
    鹡кǹ÷ӧҹ
    
    Option Explicit
    
    ' ҹ´ ...
    ' http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/cmd.mspx?mfr=true
    ' ҹͧ÷ Redirect
    ' http://www.uv.tietgen.dk/staff/mlha/PC/Soft/DOS/com/
    
    Private Sub Form_Load()
        Me.Move (Screen.Width - Width) \ 2, (Screen.Height - Height) \ 2
        
        txtMACAddress.Text = ""
        Timer1.Enabled = False
        
        ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        ' ¡ҹҹ MAC Address
        Call GetMACAddress
        ' ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
        
    End Sub
    
    ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' ·¡ҹҹ Command DOS
    ' ٨ͧ ... Թҡ ... Ҩҡ   ѹШ
    ' ෤С件֧˹ ... ҡҹ ѹ ...
    ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Private Sub GetMACAddress()
    On Error GoTo ErrHandler
        
        
        Dim sCommand As String  ' 觼ҹ DOS
        Dim strData As String   ' ҹҨҡ Text File к÷Ѵ
        
        ' Ǩͺ ... ҡź (Kill) 
        If Dir(App.Path & "\MyIPConfig.txt") <> "" Then Kill App.Path & "\MyIPConfig.txt"
        
        ' ASCII Code 34    ͧ Double Quote (")
        sCommand = "ipconfig /all > " & Chr(34) & App.Path & "\MyIPConfig.txt" & Chr(34)
        ' 觨繵ͧͧ Double Quote (") ¹ФѺ ..  ...
        ' ipconfig /all > "G:\Project VB60\GetMACAddress\MyIPConfig.txt"
        ' ͧ > ( Redirect) 繡¹ȷҧ͡ѧ (᷹͡˹ҨҾ)
        
        ' ѹ cmd е¤ DOS ͷ
        Shell ("cmd /c " & sCommand)
        ' Option /c  ѹ Դ˹ҵҧ DOS ˹ ͧ ...  55555+
        
        ' ͧѹӧҹԹ (ҧմ) ... ˹ǧѡԹҷ (500 millisecond)
        ' 蹹ѹ Դ Error 53  File not found. ... ͼͧͺ
        If Dir(App.Path & "\MyIPConfig.txt") = "" Then DelayTime (500)
        
        ' Դҹ
        Open App.Path & "\MyIPConfig.txt" For Input As #1
        
        Do While Not EOF(1)
    
            ' ҹҷк÷Ѵ
            Line Input #1, strData
            ' 觡ä¡â÷Ѵ繪ͧҧ͡
            '  ... ÷Ѵ˹բ ǹͺѺź÷Ѵ
            If Trim(strData) <> "" Then
                ' ǨͺҤ Physical Address к÷Ѵ
                If InStr(Trim(strData), "Physical Address") Then
                    '  ... Ѻѡ (Character) ҡҧҷ 17 
                    '  ... 00-00-00-FF-FF-FF
                    txtMACAddress.Text = "MAC Address : " & Right$(strData, 17)
                    Exit Do
                End If
            End If
            
        Loop
        
    ExitProc:
        ' Դ Text File
        Close #1
        Exit Sub
    
    ErrHandler:
        
        ' ¤駷ҵͧҴѡԴҴ (Trap Error)
        MsgBox Err.Number & " : " & Err.Description
        ' ҡ Resume Next ...  ⴴ价ӧҹͨҡ÷ѴԴ Error ѹ
        ' ҡ Resume ExitProc ...  ⴴ价 ExitProc
        ' ҡ Resume ...  Ѻ价ӧҹӺ÷ѴԴ Error
        Resume
        
        '  Resume   ... ҹ觺÷Ѵ ...
        ' ͹ Exit Sub ¤  ... 55555+
    
    End Sub
    
    ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    ' ǹͧ˹ǧ (Delay Time)
    ' '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
    Public Sub DelayTime(MilliSec As Long)
        ' ˹ MilliSecond 繾Ѻҡ˹ǧ
        ' Turn Timer1 On - Դ
        Timer1.Enabled = True
        Timer1.Interval = MilliSec
            ' ѹùФѺ ... ͧ
            While Timer1.Interval > 0
                ' ׹ CPU ѺкԺѵԡ (Operating System - OS) 价ӧҹҧ蹵
                DoEvents
            Wend
            ' Turn Timer1 Off - Դ
            Timer1.Enabled = False
    End Sub
    
    Private Sub Timer1_Timer()
        ' Դ÷ӧҹͧ Timer1
        Timer1.Enabled = False
        Timer1.Interval = 0
    End Sub
    
    Conclusion:
    ͧѺ ... ҴѡçẺ §ѹ ҹ Ѻöйªҧҡ ͡鴴ҹҧ ҡҡ ͧ ͼ դ繵ͧ觾 WinAPI 32 ҹѡе¤Ѻ ( DOS ¹) ...
    
    net config rdr > NetConfig.txt
    Computer name                        \\THONGKORN
    Full Computer name                   Thongkorn
    User name                            Administrator
    
    Workstation active on                
    	NetbiosSmb (000000000000)
    	NetBT_Tcpip_{6339B9DD-B200-4E47-82B9-D5A8E053FE89} (00FFFFFFFFFF)
    
    Software version                     Windows 2002
    
    Workstation domain                   WORKGROUP
    Workstation Domain DNS Name          (null)
    Logon domain                         THONGKORN
    
    COM Open Timeout (sec)               0
    COM Send Count (byte)                100
    COM Send Timeout (msec)              250
    The command completed successfully.
    

  • ͵ - g2gNet Dot Com
    Ţ¹ҳԪ硷͹ԡ 0407314800231
    CopyLeft © 2004 - 2099 g2gNet.Com All rights reserved.
    Email: [email protected] . 08-6862-6560