Chilkat Examples

ChilkatHOMEAndroid™AutoItCC#C++Chilkat2-PythonCkPythonClassic ASPDataFlexDelphi DLLGoJavaNode.jsObjective-CPHP ExtensionPerlPowerBuilderPowerShellPureBasicRubySQL ServerSwiftTclUnicode CUnicode C++VB.NETVBScriptVisual Basic 6.0Visual FoxProXojo Plugin

DataFlex Examples
Web API Categories

ASN.1
AWS KMS
AWS Misc
Amazon EC2
Amazon Glacier
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Key Vault
Azure Service Bus
Azure Table Service
Base64
Bounced Email
Box
CAdES
CSR
CSV
Cert Store
Certificates
Cloud Signature CSC
Code Signing
Compression
DKIM / DomainKey
DNS
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
EBICS
ECC
Ed25519
Email Object
Encryption
FTP
FileAccess
Firebase
GMail REST API
GMail SMTP/IMAP/POP
Geolocation
Google APIs
Google Calendar
Google Cloud SQL
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)
Java KeyStore (JKS)
MHT / HTML Email
MIME
Microsoft Graph
Misc
NTLM
OAuth1
OAuth2
OIDC
Office365
OneDrive
OpenSSL
Outlook
Outlook Calendar
Outlook Contact
PDF Signatures
PEM
PFX/P12
PKCS11
POP3
PRNG
REST
REST Misc
RSA
SCP
SCard
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
ScMinidriver
Secrets
SharePoint
SharePoint Online
Signing in the Cloud
Socket/SSL/TLS
Spider
Stream
Tar Archive
ULID/UUID
Upload
WebSocket
X
XAdES
XML
XML Digital Signatures
XMP
Zip
curl
uncategorized

 

 

 

(DataFlex) Get Network Adapter IP and MAC Addresses

Retrieves network adapter information, including IP addresses (IPv4 and IPv6) and MAC addresses.

Note: This example requires Chilkat v10.1.3 or later.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

Use ChilkatAx-win32.pkg

Procedure Test
    Handle hoSocket
    Variant vJson
    Handle hoJson
    Boolean iSuccess
    String sMacAddress
    String sTemp1
    Boolean bTemp1

    Get Create (RefClass(cComChilkatSocket)) To hoSocket
    If (Not(IsComObjectCreated(hoSocket))) Begin
        Send CreateComObject of hoSocket
    End
    Get Create (RefClass(cComChilkatJsonObject)) To hoJson
    If (Not(IsComObjectCreated(hoJson))) Begin
        Send CreateComObject of hoJson
    End

    Set ComEmitCompact Of hoJson To False

    // Note: The GetAdaptersAddresses method was added in Chilkat v10.1.3.
    Get pvComObject of hoJson to vJson
    Get ComGetAdaptersAddresses Of hoSocket vJson To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoSocket To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComEmit Of hoJson To sTemp1
    Showln sTemp1

    // Here are some example results for Windows, Linux, and MacOS:

    // -------------------------------------------------------
    // Windows sample output

    // {
    //   "adapters": [
    //     {
    //       "name": "Ethernet",
    //       "description": "Intel(R) Ethernet Connection (2) I219-LM",
    //       "mac": "7C-D3-0B-25-DA-1C",
    //       "ipv6": "fe80::1758:bec3:b2b8:7045",
    //       "ipv4": "172.16.16.24"
    //     },
    //     {
    //       "name": "Ethernet 2",
    //       "description": "VirtualBox Host-Only Ethernet Adapter",
    //       "mac": "0A-00-27-00-00-0B",
    //       "ipv6": "fe80::19e6:8a84:527b:2f0e",
    //       "ipv4": "192.168.56.1"
    //     },
    //     {
    //       "name": "Bluetooth Network Connection",
    //       "description": "Bluetooth Device (Personal Area Network)",
    //       "mac": "F0-D5-BB-CE-6F-89",
    //       "ipv6": "fe80::d94e:c01e:433e:2049",
    //       "ipv4": "169.254.203.20"
    //     },
    //     {
    //       "name": "Loopback Pseudo-Interface 1",
    //       "description": "Software Loopback Interface 1",
    //       "mac": "",
    //       "ipv6": "::1",
    //       "ipv4": "127.0.0.1"
    //     }
    //   ]
    // }

    // Note: The "description" element is only present when run on Windows.
    // Here's sample code to get the MAC address for the "Ethernet" adapter
    Get ComFindRecordString Of hoJson "adapters" "name" "Ethernet" True "mac" To sMacAddress
    Get ComLastMethodSuccess Of hoJson To bTemp1
    If (bTemp1 = False) Begin
        Showln "Failed to find MAC address for the Ethernet adapter"
    End
    Else Begin
        Showln "MAC address: " sMacAddress
    End

    // -------------------------------------------------------
    // Linux Sample Output:

    // {
    //   "adapters": [
    //     {
    //       "name": "lo",
    //       "mac": "",
    //       "ipv4": "127.0.0.1",
    //       "ipv6": "::1"
    //     },
    //     {
    //       "name": "eth0",
    //       "mac": "50-9A-4C-43-15-56",
    //       "ipv4": "172.16.16.28",
    //       "ipv6": "fe80::529a:4cff:fe43:1556"
    //     }
    //   ]
    // }

    // -------------------------------------------------------
    // Android:

    // On Android, accessing the MAC address directly is restricted on modern Android versions (API level 23 and above) due to privacy and security concerns. 
    // Apps targeting Android 6.0 (API level 23) or higher cannot access the MAC address of the device using standard APIs.
    // If you're developing for modern Android, consider using alternative identifiers (e.g., instance IDs) instead of the MAC address, as recommended by Google.
    // 
    // Chilkat will not return MAC addresses for Android, regardless of the API level.
    // Only IP addresses are returned for Android.

    // -------------------------------------------------------
    // MacOS Sample Output:

    // See Understanding MacOS Network Inteface Names

    // {
    //   "adapters": [
    //     {
    //       "name": "lo0",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv4": "127.0.0.1",
    //       "ipv6": "::1",
    //       "ipv6_linkLocal": "fe80::1"
    //     },
    //     {
    //       "name": "gif0",
    //       "mac": "00-00-00-00-00-00"
    //     },
    //     {
    //       "name": "stf0",
    //       "mac": "00-00-00-00-00-00"
    //     },
    //     {
    //       "name": "anpi1",
    //       "mac": "DE-CF-89-6B-85-18"
    //     },
    //     {
    //       "name": "anpi0",
    //       "mac": "DE-CF-89-6B-85-17"
    //     },
    //     {
    //       "name": "en0",
    //       "mac": "14-98-77-38-2A-47",
    //       "ipv6": "fe80::1cf4:e6db:6159:a9d5",
    //       "ipv4": "172.16.16.30"
    //     },
    //     {
    //       "name": "en7",
    //       "mac": "DE-CF-89-6B-85-F7"
    //     },
    //     {
    //       "name": "en8",
    //       "mac": "DE-CF-89-6B-85-F8"
    //     },
    //     {
    //       "name": "en2",
    //       "mac": "36-69-36-B0-29-C0"
    //     },
    //     {
    //       "name": "en3",
    //       "mac": "36-69-36-B0-29-C4"
    //     },
    //     {
    //       "name": "bridge0",
    //       "mac": "36-69-36-B0-29-C0"
    //     },
    //     {
    //       "name": "ap1",
    //       "mac": "36-98-77-45-45-EC",
    //       "ipv6": "fe80::3498:77ff:fe45:45ec"
    //     },
    //     {
    //       "name": "en1",
    //       "mac": "14-98-77-45-45-EC",
    //       "ipv6": "fe80::149b:a396:ca4e:f18d",
    //       "ipv4": "192.168.1.224"
    //     },
    //     {
    //       "name": "awdl0",
    //       "mac": "DE-4C-F0-5C-17-F9",
    //       "ipv6": "fe80::dc4c:f0ff:fe5c:17f9"
    //     },
    //     {
    //       "name": "llw0",
    //       "mac": "DE-4C-F0-5C-17-F9",
    //       "ipv6": "fe80::dc4c:f0ff:fe5c:17f9"
    //     },
    //     {
    //       "name": "utun0",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv6": "fe80::b3b3:cfbe:5790:9573"
    //     },
    //     {
    //       "name": "utun1",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv6": "fe80::e5:677f:9f70:7ad"
    //     },
    //     {
    //       "name": "utun2",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv6": "fe80::ce81:b1c:bd2c:69e"
    //     },
    //     {
    //       "name": "utun3",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv6": "fe80::87e5:c723:bbd:6656"
    //     },
    //     {
    //       "name": "utun4",
    //       "mac": "00-00-00-00-00-00",
    //       "ipv6": "fe80::cb13:ae1a:9de3:392e"
    //     }
    //   ]
    // }
    // 


End_Procedure

 

© 2000-2025 Chilkat Software, Inc. All Rights Reserved.