Solved

GetNetworkParams

Posted on 2004-09-28
10
781 Views
Last Modified: 2008-01-09
I am having problems getting the GetNetworkParams() API Function. Does anyone have any example code for this api function?

Thanks for your help.

SohilM.
0
Comment
Question by:sohilm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
10 Comments
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12173940
What information are you trying to retrieve?

Bob
0
 
LVL 3

Author Comment

by:sohilm
ID: 12173977
The DNS Server List. I also need to get the gateway and mac address for the primary adapter. I understand that is in the getadaptersinfo() api call, but I haven't looked into it.

Thanks
Sohil M.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 12173995
Are you talking about these settings from ipconfig /all:

Windows IP Configuration

        Host Name
        Primary Dns Suffix
        Node Type
        IP Routing Enabled
        WINS Proxy Enabled
        DNS Suffix Search List

Ethernet adapter Local Area Connection:

        Connection-specific DNS Suffix  
        Description
        Physical Address
        Dhcp Enabled
        Autoconfiguration Enabled
        IP Address
        Subnet Mask
        Default Gateway
        DHCP Server
        DNS Servers
        Primary WINS Server
        Lease Obtained
        Lease Expires

Bob
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Assisted Solution

by:Bob Learned
Bob Learned earned 250 total points
ID: 12174053
VB.NET code to get MAC address and Gateway:

imports System
imports System.Management

Public Class WMICardGrab
Public Shared Sub Main()
Dim query as ManagementObjectSearcher = new _
ManagementObjectSearcher("SELECT * FROM
WIN32_NetworkAdapterConfiguration WHERE IPEnabled = 'TRUE'")
Dim queryCollection as ManagementObjectCollection = query.Get()
Dim mo as ManagementObject
For Each mo In queryCollection
Dim addresses() as string = CType(mo("IPAddress"), string())
Dim defaultgateways() as string = CType(mo("DefaultIPGateway"),
string())

Console.WriteLine("Network Card: {0}", mo("Description"))
Console.WriteLine(" MAC Address: {0}", mo("MACAddress"))

Dim ipaddress as string
For Each ipaddress In addresses
Console.WriteLine(" IP Address: {0}", ipaddress)
Next

Dim gateway as string
For Each gateway In defaultgateways
Console.WriteLine(" Gateway: {0}", gateway)
Next
Next
End Sub
End Class


Bob
0
 
LVL 3

Author Comment

by:sohilm
ID: 12174064
I need to use the api call, I can't use wmi. I don't have a guarantee that all these machines have wmi.
0
 
LVL 11

Accepted Solution

by:
Agarici earned 250 total points
ID: 12177479
here is the msdn link to GetNetworkParams:http://msdn.microsoft.com/library/default.asp?url=/library/en-us/iphlp/iphlp/getnetworkparams.asp
if you need help porting it to .net (and it seems this is the case) here is the vb.net version:
http://www.dotnet247.com/247reference/msgs/18/91898.aspx


hth,
A.
0
 
LVL 3

Author Comment

by:sohilm
ID: 12179476
I need it for C#, when I port it, I don't get an error value. The application just dies. Any ideas?
0
 
LVL 11

Expert Comment

by:Agarici
ID: 12179603
if you post the code you use, maybe we can do some debugging...


hth,
A.
0
 
LVL 3

Author Comment

by:sohilm
ID: 12179699
I deleted the class. Let me see if I can rewrite it.
0
 
LVL 3

Author Comment

by:sohilm
ID: 12243448
Thanks for everyone's help. I ended up going with wmi, and just forced the users to have wmi setup.

Thanks
SohilM.
0

Featured Post

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
In this video, viewers will be given step by step instructions on adjusting mouse, pointer and cursor visibility in Microsoft Windows 10. The video seeks to educate those who are struggling with the new Windows 10 Graphical User Interface. Change Cu…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question