Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8631191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:11:04+00:00 2026-06-12T09:11:04+00:00

Is there any way to discover if a local network interface has it’s address

  • 0

Is there any way to discover if a local network interface has it’s address assigned via DHCP or if it is statically set through Java?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:11:05+00:00Added an answer on June 12, 2026 at 9:11 am

    So, as you requested Win NT ‘solution’ only, here is my code.It lists network interfaces with current configured values.

    Note EnableDHCP registry key value, I think this is the point.

    As I already mentioned in comment under your question, you need as least simple JNI wrapper.

    Hope this helps.

    more info here : http://support.microsoft.com/kb/314053

    #include <windows.h>
    
    #define NETCARD_ROOT    L"SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\NetworkCards"
    #define TCPIP_ROOT  L"SYSTEM\\CurrentControlSet\\services\\Tcpip\\Parameters\\Interfaces"
    
    int _tmain(int argc, _TCHAR* argv[])
    {
    
        //First enumerate all network adapters
    
        HKEY hNetCardsKey;
        LSTATUS lStatus = ERROR_SUCCESS;
    
        lStatus = RegOpenKey(HKEY_LOCAL_MACHINE, 
            NETCARD_ROOT, 
            &hNetCardsKey);
    
        if(ERROR_SUCCESS == lStatus)
        {
            DWORD dwCards = 0L;
            DWORD dwMaxSubkeyNameLen = 0L;
            lStatus = RegQueryInfoKey(hNetCardsKey, NULL, NULL, NULL, &dwCards, 
                &dwMaxSubkeyNameLen, NULL, NULL, NULL, NULL, NULL, NULL);
    
            if(ERROR_SUCCESS == lStatus && dwCards)
            {
                for(DWORD i = 0; i < dwCards; i++)
                {
                    TCHAR wszCurrentCardIdxName[MAX_PATH];
                    wszCurrentCardIdxName[0] = '\0';
                    lStatus = RegEnumKey(hNetCardsKey, i, 
                        wszCurrentCardIdxName, MAX_PATH);
    
                    if(ERROR_SUCCESS == lStatus)
                    {
                        TCHAR wszAdapterKeyName[MAX_PATH];
                        wszAdapterKeyName[0] = '\0';
    
                        wsprintf(wszAdapterKeyName, L"%s\\%s", NETCARD_ROOT, 
                            wszCurrentCardIdxName);
    
                        HKEY hCardNameKey;
    
                        lStatus = RegOpenKey(
                            HKEY_LOCAL_MACHINE, 
                            wszAdapterKeyName, 
                            &hCardNameKey);
    
                        if(ERROR_SUCCESS == lStatus)
                        {
                            TCHAR wszServiceNameGuid[MAX_PATH];
                            TCHAR wszAdapterName[MAX_PATH];
    
                            DWORD dwSize = sizeof(wszServiceNameGuid);
                            wszServiceNameGuid[0] = '\0';
                            RegQueryValueEx(
                                hCardNameKey, 
                                L"ServiceName",
                                NULL, 
                                NULL,
                                (LPBYTE)wszServiceNameGuid,
                                &dwSize);
    
                            dwSize = sizeof(wszAdapterName);
                            RegQueryValueEx(
                                hCardNameKey, 
                                L"Description",
                                NULL, 
                                NULL,
                                (LPBYTE)wszAdapterName,
                                &dwSize);
    
                            OutputDebugStringW(wszServiceNameGuid);
                            OutputDebugStringW(L"\n");
    
                            RegCloseKey(hCardNameKey);
    
                            //Get parameters
                            TCHAR wszCardParamKey[MAX_PATH];
                            wszCardParamKey[0] = '\0';
                            wsprintf(wszCardParamKey,L"%s\\%s", TCPIP_ROOT, wszServiceNameGuid);
    
                            HKEY hParamKey = NULL;
    
                            lStatus = RegOpenKey(
                                HKEY_LOCAL_MACHINE, 
                                wszCardParamKey, 
                                &hParamKey);
    
                            if(ERROR_SUCCESS == lStatus)
                            {
                                DWORD dwEnabledDHCP = 0L;
                                DWORD dwDWSize = sizeof(DWORD);
                                TCHAR wszStaticIP[32];
                                TCHAR wszDHCPIP[32];
                                DWORD dwIPSize = sizeof(wszDHCPIP);
    
                                ZeroMemory(wszDHCPIP, dwIPSize);
                                ZeroMemory(wszStaticIP, dwIPSize);
    
                                lStatus = RegQueryValueEx(
                                    hParamKey, 
                                    L"EnableDHCP", 
                                    NULL, NULL, 
                                    (LPBYTE)&dwEnabledDHCP, 
                                    &dwDWSize);
    
                                if(SUCCEEDED(lStatus))
                                {
                                    wprintf_s(L"Adapter : %s [%s] \n\tDHCP : %s\n", 
                                        wszServiceNameGuid, 
                                        wszAdapterName,
                                        dwEnabledDHCP 
                                        ? L"Yes" : L"No");
                                }
    
                                lStatus = RegQueryValueEx(
                                    hParamKey, 
                                    L"IPAddress", 
                                    NULL, 
                                    NULL, 
                                    (LPBYTE)&wszStaticIP, 
                                    &dwIPSize);
    
                                if(SUCCEEDED(lStatus))
                                {
                                    wprintf_s(L"\tConfigured IP Address : %s\n", wszStaticIP);
                                }
    
                                dwIPSize = sizeof(wszDHCPIP);
                                lStatus = RegQueryValueEx(
                                    hParamKey, 
                                    L"DhcpIPAddress", 
                                    NULL, 
                                    NULL, 
                                    (LPBYTE)&wszDHCPIP, 
                                    &dwIPSize);
    
                                if(SUCCEEDED(lStatus))
                                {
                                    wprintf_s(L"\tDHCP IP Address : %s\n", wszDHCPIP);
                                }
    
                                wprintf_s(L"\n");
    
                                RegCloseKey(hParamKey);
                            }
    
                        }
                    }
                }
            }
    
    
            RegCloseKey(hNetCardsKey);
        }
    
    
        return 0;
    }
    

    Simple output:

    Adapter : {6EC2554F-3359-43A2-AADB-57F427DC72FC} [Marvell Yukon 88E8072 PCI-E Gigabit Ethernet Controller]
            DHCP : No
            Configured IP Address : 192.168.5.10
            DHCP IP Address : 192.168.1.102
    
    Adapter : {2A28BDA8-ED1D-4E6E-8990-485EE1836828} [Sony Ericsson Device 0016 USB Ethernet Emulation (NDIS 5)]
            DHCP : Yes
            Configured IP Address :
            DHCP IP Address : 0.0.0.0
    
    Adapter : {491DC095-155F-4572-B975-2E1703C17632} [Microsoft Windows Mobile Remote Adapter]
            DHCP : Yes
            Configured IP Address :
            DHCP IP Address : 169.254.2.2
    
    Adapter : {5F987E64-E804-42DA-9453-8E479B6FC835} [Broadcom 802.11b/g Network adapter]
            DHCP : Yes
            Configured IP Address :
            DHCP IP Address : 192.168.1.14
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any way I can set a formatter on models that will convert
Is there any way to discover what charset encoding a file is using?
In Java, is there any way to use the JDK libraries to discover the
Is there any way in Notepad++ (or even with another tool) to change the
Is there any way to use Google's API to retrieve a user's current zipcode
Is there any way to overload the > (greater than) operator, to be able
Is there any way we can fetch X509 Public Cetrificates using c# from AD
Is there any way to stop animation in iOS 3 ? I know about:
Is there any way to update nested documents by id or some other field?
Is there any way in which I can automatically convert a Custom Class Object

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.