Good day, guru.

There is a question how on C #, WinForm, to make determination of a subject?

The output to the console is clear, but how to paste it into a label, so that when the program is started, the information is simply displayed as text, it is not very clear.

Thank you in advance for your response.

  • one
    So you have a problem with getting data or outputting it in a label? - Max Zhukov
  • And with that and with another. Ie in the console, I get data on ip, but the address is only zero, and with the output to the label nothing happened at all - VaLenOK007

2 answers 2

MAC address:

public string GetMACAddress() { ManagementObjectSearcher objMOS = new ManagementObjectSearcher("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection objMOC = objMOS.Get(); string MACAddress = String.Empty; foreach (ManagementObject objMO in objMOC) { if (MACAddress == String.Empty) { MACAddress = objMO["MacAddress"].ToString(); } objMO.Dispose(); } MACAddress = MACAddress.Replace(":", ""); return MACAddress; } 

Label output - write in the form constructor

 label1.Text = (ваши_данные); 

    You can get IP in different ways, for example:

     WebClient webclient = new WebClient(); string ip = webclient.DownloadString("http://checkip.dyndns.com/"); ip = ip.Substring("<html><head><title>Current IP Check</title></head><body>Current IP Address: ".Length).Replace("</body></html>","");//Вытащить можно и по-другому label1.Text = ip;