Is there a way to get the computer's MAC address in Windows ?
Annick Fron _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
On Sep 4, 2008, at 5:13 PM, Annick Fron wrote: > Is there a way to get the computer's MAC address in Windows ? I don't have a Windows machine here so I cannot check but I think the 'ipconfig' command line tool shows mac addresses (try "ipconfig /all"). Alternatively use DLLCC, here's a message with a suggested C skeleton program: http://groups.google.com/group/comp.os.ms-windows.programmer.win32/msg/beb4290fd18ed1d9 R - > > > Annick Fron > > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Annick
Annick Fron wrote:
> Is there a way to get the computer's MAC address in Windows ? A simple and quick and dirty way (not language independent unfortunately) would be: | proc str index str2 str3 | proc := WinProcess new. str := proc executeSingleCommand: 'ipconfig /all' . index := str indexOfSubCollection: 'Physikalische Adresse' startingAt:1. index := index + ('Physikalische Adresse' size). str2 := str copyFrom: index to: index + 100. "just arbitrary number" str3 := str2 copyUpTo: Core.Character cr. "the first cr notes the end of the line" str3 copyFrom: ((str3 indexOf: $:) +1) to: (str3 size -1). "trim blanks" For 'Physikalische Adresse' you have to include whatever physical address means in your language. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Reinout Heeck
Le 4 sept. 08 à 17:29, Reinout Heeck a écrit : > > On Sep 4, 2008, at 5:13 PM, Annick Fron wrote: > >> Is there a way to get the computer's MAC address in Windows ? > > I don't have a Windows machine here so I cannot check but I think the > 'ipconfig' command line tool shows mac addresses > (try "ipconfig /all"). Yes this work using ExternalProcess ... > > > Alternatively use DLLCC, here's a message with a suggested C skeleton > program: > > http://groups.google.com/group/comp.os.ms- > windows.programmer.win32/msg/beb4290fd18ed1d9 > > > R > - Thank you > > > >> >> >> Annick Fron >> >> >> _______________________________________________ >> vwnc mailing list >> [hidden email] >> http://lists.cs.uiuc.edu/mailman/listinfo/vwnc >> > > _______________________________________________ > vwnc mailing list > [hidden email] > http://lists.cs.uiuc.edu/mailman/listinfo/vwnc > _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
In reply to this post by Claus Kick
I would recommend parsing regular CSV from,
H:\>getmac /FO CSV /V "Connection Name","Network Adapter","Physical Address","Transport Name" "Local Area Connection","Broadcom NetXtreme 57xx Gigabit Controller","00-19-B9-00-17-CE","\Device\Tcpip_{1CFCEB4C-2BD7-4D3F-AE5D- DDE0462C2860}" "VMware Network Adapter VMnet1","VMware Virtual Ethernet Adapter for VMnet1","00-50-56-C0-00-01","\Device\Tcpip_{10B398CA-5D59-4771-9B9F-D601 DAC91331}" "VMware Network Adapter VMnet8","VMware Virtual Ethernet Adapter for VMnet8","00-50-56-C0-00-08","\Device\Tcpip_{B6C646D0-F1D0-46F1-A64F-4A69 D7966A98}" Cheers, -Boris -- +1.604.689.0322 DeepCove Labs Ltd. 4th floor 595 Howe Street Vancouver, Canada V6C 2T5 http://tinyurl.com/r7uw4 [hidden email] CONFIDENTIALITY NOTICE This email is intended only for the persons named in the message header. Unless otherwise indicated, it contains information that is private and confidential. If you have received it in error, please notify the sender and delete the entire message including any attachments. Thank you. -----Original Message----- From: [hidden email] [mailto:[hidden email]] On Behalf Of Claus Kick Sent: September 4, 2008 9:12 AM To: VW NC Subject: Re: [vwnc] Mac address Annick Fron wrote: > Is there a way to get the computer's MAC address in Windows ? A simple and quick and dirty way (not language independent unfortunately) would be: | proc str index str2 str3 | proc := WinProcess new. str := proc executeSingleCommand: 'ipconfig /all' . index := str indexOfSubCollection: 'Physikalische Adresse' startingAt:1. index := index + ('Physikalische Adresse' size). str2 := str copyFrom: index to: index + 100. "just arbitrary number" str3 := str2 copyUpTo: Core.Character cr. "the first cr notes the end of the line" str3 copyFrom: ((str3 indexOf: $:) +1) to: (str3 size -1). "trim blanks" For 'Physikalische Adresse' you have to include whatever physical address means in your language. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Using ifconfig or external process seems odd, somehow to me. The
problem is which interface are you looking for? Local loopback? The
wired interface? The wifi one? What if you have multiple of either or
all? Additionally, parsing the output of an external command isn't
without its own challenges.
I had a similar problem from a shell script, and so wrote the following C code to solve it. The command takes a single argument, which is the interface. #include <stdio.h> -- Visit <http://tggagne.blogspot.com/> for more great reading. _______________________________________________ vwnc mailing list [hidden email] http://lists.cs.uiuc.edu/mailman/listinfo/vwnc |
Free forum by Nabble | Edit this page |