C++ Mac Address
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 9 of 9

Thread: C++ Mac Address

  1. #1
    Join Date
    Sep 2009
    Posts
    3

    C++ Mac Address

    How do i get the mac address of the computer it is run on and return it using a
    Code:
    char macchar[50]
    variable (i know strings work better but i need to use chars for my project I'm working on)

  2. #2
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: C++ Mac Address

    You can achieve this by simple piece of dos command.


    ipconfig /all >> [path]

    path should be a txt file location in which you will get all the NIC MAC address. Then you just need to manipulate it a bit more to server your purpose.

  3. #3
    Join Date
    Sep 2009
    Posts
    3

    Re: C++ Mac Address

    I'm sort-of a self taught newbie with c++ i don't get what you mean.... i need step by step please if you are willing.

  4. #4
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: C++ Mac Address

    See.. 1st place the dos command "ipconfig /all" (without quotes) into dos and see the output. you will find all the mac of ur nics. then you just need to catch this mac address in ur c++ code.. better u start off c++ file handling before doing this..

  5. #5
    Join Date
    Sep 2009
    Posts
    3

    Re: C++ Mac Address

    c++ file handling.... is that out.put and in.get? because i use that all the time.

  6. #6
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: C++ Mac Address

    what do u mean by out.put. Is this file pointers?. start off with good book. u can use H. Shildt C/C++ Complete reference.

  7. #7
    Join Date
    Mar 2003
    Location
    India {Mumbai};
    Posts
    3,871

    Re: C++ Mac Address

    Do you need this?
    How to get my IP address?

    And don't use any sort of command redirection into file, and parsing the file. That is absurd. A command window may open, would distract the user. And most importantly, output of any command (like 'ipconfig') may change by different versions of OS.
    My latest article: Explicating the new C++ standard (C++0x)

    Do rate the posts you find useful.

  8. #8
    Join Date
    Jul 2009
    Location
    India
    Posts
    835

    Re: C++ Mac Address

    ya that is always better if you can code for network programming

  9. #9
    Join Date
    Feb 2005
    Posts
    2,160

    Re: C++ Mac Address

    Quote Originally Posted by Ajay Vijay View Post
    Do you need this?
    How to get my IP address?

    And don't use any sort of command redirection into file, and parsing the file. That is absurd. A command window may open, would distract the user. And most importantly, output of any command (like 'ipconfig') may change by different versions of OS.
    MAC address, not IP address.

    OP: See the IP Helper API:

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center