How to obtain the network card serial number

Source: Internet
Author: User

Method 1

Connect to the netapi32.lib library, define an NCB struct, and then call netbois (NCB) to obtain the serial number.

If NetBIOS is disabled, the serial number cannot be obtained.

Method 2

It is of little practical value to call the ipconfig command to obtain the result.

Method 3: Use the SNMP protocol

Read loadlibrary ("inetmib1.dll ");

Obtain the function addresses of snmpextensioninit, snmpextensioninitex, snmpextensionquery, and snmpextensiontrap In the DLL, and then fill asnobjectidentifier with snmp_oidcpy to obtain the parameters of the NIC.

Another method is:

Include "iphlpapi. H"

 

# Pragma comment (Lib, "iphlpapi. lib ")

 

Bool getmacaddress (cstring & straddress)
{
Ip_adapter_info adapterinfo [16]; // defines the NIC information storage area.
DWORD dwbuflen = sizeof (adapterinfo );

 

DWORD dwstatus = getadaptersinfo (
Adapterinfo, // [Output] pointing to the received data buffer pointer
& Dwbuflen); // [input] buffer size
If (dwstatus! = Error_success)
Return false;

 

Straddress. Format ("% 02x: % 02x: % 02x: % 02x: % 02x: % 02x ",
Adapterinfo-> Address [0],
Adapterinfo-> Address [1],
Adapterinfo-> Address [2],
Adapterinfo-> Address [3],
Adapterinfo-> Address [4],
Adapterinfo-> Address [5]);
Return true;
}
However, the premise is that a new SDK has not been tested.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.