Hello all,
I'm new to the wxWidgets scene and have a couple projects I'm starting to work on that I'm attempting to develop for at least linux and windows. One thing I'd like to be able to do is obtain the MAC address inside the program. Is there a straightforward way to go about this? My google searches have primarily turned up platform-dependent solutions such as the windows method "GetAdaptersInfo." I've gone through the documentation a bit, though my experience with wxWidgets is essentially nill so far. Can anyone tell me if the socket library provides this functionality, or if there is another way to go about obtaining the information I'm looking for?
Thanks,
Jeremy Brown
obtaining MAC address? Topic is solved
Re: obtaining MAC address?
Hi!
I'd suggest that you write a simple function prototype for all platforms, so that you can use it anywhere and implement the platform dependent stuff by using ifdefs for the specific platform.
See here for the "windows"-ways of doing this ( GetAdapteraInfo would be the best IMHO ): http://www.codeguru.com/Cpp/I-N/network ... .php/c5451
Here's a hint how to do it using Linux: http://cplus.kompf.de/artikel/macaddr.html
I'm afraid doublemax is right. The MAC address is not related to sockets, but to the specific adapters installed in your system. wxWidgets offer no way to obtain these.jdbrown wrote:Can anyone tell me if the socket library provides this functionality, or if there is another way to go about obtaining the information I'm looking for?
I'd suggest that you write a simple function prototype for all platforms, so that you can use it anywhere and implement the platform dependent stuff by using ifdefs for the specific platform.
See here for the "windows"-ways of doing this ( GetAdapteraInfo would be the best IMHO ): http://www.codeguru.com/Cpp/I-N/network ... .php/c5451
Here's a hint how to do it using Linux: http://cplus.kompf.de/artikel/macaddr.html
OS: OpenSuSE, Ubuntu, Win XP Pro
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
wx: svn
Compiler: gcc 4.5.1, VC 2008, eVC 4
"If it was hard to write it should be hard to read..." - the unknown coder
"Try not! Do. Or do not. There is no try." - Yoda
-
- Knows some wx things
- Posts: 40
- Joined: Fri Aug 10, 2007 10:37 pm
-
- Knows some wx things
- Posts: 40
- Joined: Fri Aug 10, 2007 10:37 pm
Its working fine for me
I have used the code project code directly in windows.
[/code]
I have used the code project code directly in windows.
Code: Select all
int main(int argc, char **argv){
wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
wxInitializer initializer;
if ( !initializer )
{
fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
return -1;
}
GetMACaddress();
GetMACNetBiosAddress();
GetMACAdapterAddress();
return 0;
}