Bonsoir tout le monde,

J'ai récupéré sur un site une source en C# réalisé avec VS2003 que j'aimerais beaucoup convertir en VB.NET 2.0 afin de la réutiliser au sein de mon programme mais j'ai beaucoup de mal car je ne connais pas du tout le C#. Si l'un d'entre vous pouvez m'aider je l'en remercierai grandement.

Voici la source en question : http://rc200x.free.fr/temp/HostNIPAddr.rar

et son code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;
using System.Net;
using System.DirectoryServices;
using System.Runtime.InteropServices;
 
 
namespace HostNIPAddr
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		internal System.Windows.Forms.Button ButClose;
		internal System.Windows.Forms.Button ButDisplay;
		internal System.Windows.Forms.ListView ListHostIP;
		internal System.Windows.Forms.ColumnHeader HostName;
		internal System.Windows.Forms.ColumnHeader IpAddr;
		internal System.Windows.Forms.StatusBar Status;
		private System.Windows.Forms.TextBox TxtWorkGroup;
		private System.Windows.Forms.Label label1;
		private System.Windows.Forms.ColumnHeader PhyAdd;
 
		[DllImport("iphlpapi.dll", ExactSpelling=true)]
		public static extern int SendARP( int DestIP, int SrcIP, [Out] byte[] pMacAddr, ref int PhyAddrLen );
 
 
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;
 
		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();
 
			//
			// TODO: Add any constructor code after InitializeComponent call
			//
		}
 
		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if (components != null) 
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}
 
		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.ButClose = new System.Windows.Forms.Button();
			this.ButDisplay = new System.Windows.Forms.Button();
			this.ListHostIP = new System.Windows.Forms.ListView();
			this.HostName = new System.Windows.Forms.ColumnHeader();
			this.IpAddr = new System.Windows.Forms.ColumnHeader();
			this.PhyAdd = new System.Windows.Forms.ColumnHeader();
			this.Status = new System.Windows.Forms.StatusBar();
			this.TxtWorkGroup = new System.Windows.Forms.TextBox();
			this.label1 = new System.Windows.Forms.Label();
			this.SuspendLayout();
			// 
			// ButClose
			// 
			this.ButClose.Location = new System.Drawing.Point(380, 272);
			this.ButClose.Name = "ButClose";
			this.ButClose.Size = new System.Drawing.Size(84, 20);
			this.ButClose.TabIndex = 7;
			this.ButClose.Text = "Close";
			this.ButClose.Click += new System.EventHandler(this.ButClose_Click);
			// 
			// ButDisplay
			// 
			this.ButDisplay.Location = new System.Drawing.Point(380, 252);
			this.ButDisplay.Name = "ButDisplay";
			this.ButDisplay.Size = new System.Drawing.Size(84, 20);
			this.ButDisplay.TabIndex = 6;
			this.ButDisplay.Text = "Display";
			this.ButDisplay.Click += new System.EventHandler(this.ButDisplay_Click);
			// 
			// ListHostIP
			// 
			this.ListHostIP.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						 this.HostName,
																						 this.IpAddr,
																						 this.PhyAdd});
			this.ListHostIP.Location = new System.Drawing.Point(40, 16);
			this.ListHostIP.Name = "ListHostIP";
			this.ListHostIP.Size = new System.Drawing.Size(304, 272);
			this.ListHostIP.TabIndex = 5;
			this.ListHostIP.View = System.Windows.Forms.View.Details;
			// 
			// HostName
			// 
			this.HostName.Text = "Host Name";
			this.HostName.Width = 100;
			// 
			// IpAddr
			// 
			this.IpAddr.Text = "IP Address";
			this.IpAddr.Width = 100;
			// 
			// PhyAdd
			// 
			this.PhyAdd.Text = "Physical Address";
			this.PhyAdd.Width = 125;
			// 
			// Status
			// 
			this.Status.Location = new System.Drawing.Point(0, 303);
			this.Status.Name = "Status";
			this.Status.Size = new System.Drawing.Size(472, 22);
			this.Status.TabIndex = 4;
			// 
			// TxtWorkGroup
			// 
			this.TxtWorkGroup.Location = new System.Drawing.Point(352, 80);
			this.TxtWorkGroup.Name = "TxtWorkGroup";
			this.TxtWorkGroup.Size = new System.Drawing.Size(80, 20);
			this.TxtWorkGroup.TabIndex = 8;
			this.TxtWorkGroup.Text = "Baba";
			// 
			// label1
			// 
			this.label1.AutoSize = true;
			this.label1.Location = new System.Drawing.Point(356, 56);
			this.label1.Name = "label1";
			this.label1.Size = new System.Drawing.Size(98, 16);
			this.label1.TabIndex = 9;
			this.label1.Text = "Work Group Name";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(472, 325);
			this.Controls.Add(this.label1);
			this.Controls.Add(this.TxtWorkGroup);
			this.Controls.Add(this.ButClose);
			this.Controls.Add(this.ButDisplay);
			this.Controls.Add(this.ListHostIP);
			this.Controls.Add(this.Status);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.MaximizeBox = false;
			this.MaximumSize = new System.Drawing.Size(480, 352);
			this.MinimumSize = new System.Drawing.Size(480, 352);
			this.Name = "Form1";
			this.Text = "System Info";
			this.ResumeLayout(false);
 
		}
		#endregion
 
		/// <summary>
		/// The main entry point for the application.
		/// </summary>
		[STAThread]
		static void Main() 
		{
			Application.Run(new Form1());
		}
 
		private void ButDisplay_Click(object sender, System.EventArgs e)
		{
			try
			{
 
				this.Status.Text = "Collecting Information...";
 
				if(this.TxtWorkGroup.Text.Trim() == "")
				{
					MessageBox.Show("The Work Group name Should Not be Empty");
					return;
				}
 
 
				// Use Your work Group WinNT://&&&&(Work Group Name)
				DirectoryEntry DomainEntry = new DirectoryEntry("WinNT://" + this.TxtWorkGroup.Text.Trim());
				DomainEntry.Children.SchemaFilter.Add("computer");
 
 
				// To Get all the System names And Display with the Ip Address
				foreach(DirectoryEntry machine in DomainEntry.Children)
				{
					string[] Ipaddr = new string[3];
					Ipaddr[0] = machine.Name;
 
					System.Net.IPHostEntry Tempaddr = null;
 
					try
					{
						Tempaddr = (System.Net.IPHostEntry)Dns.GetHostByName(machine.Name);
					}
					catch(Exception ex)
					{
						MessageBox.Show("Unable to connect woth the system :" + machine.Name );
						continue;
					}
					System.Net.IPAddress[] TempAd = Tempaddr.AddressList;
					foreach(IPAddress TempA in TempAd)
					{
						Ipaddr[1] = TempA.ToString();
 
						byte[] ab = new byte[6];
						int len = ab.Length;
 
						// This Function Used to Get The Physical Address
						int r = SendARP( (int) TempA.Address, 0, ab, ref len );
						string mac = BitConverter.ToString( ab, 0, 6 );
 
						Ipaddr[2] = mac;
					}			
 
					System.Windows.Forms.ListViewItem TempItem = new ListViewItem(Ipaddr);
 
					this.ListHostIP.Items.Add(TempItem);
				}
 
				this.Status.Text = "Displayed";
			}
			catch(Exception ex)
			{
				MessageBox.Show(ex.Message,"Error",System.Windows.Forms.MessageBoxButtons.OK  );
				Application.Exit();
			}
 
		}
 
		private void ButClose_Click(object sender, System.EventArgs e)
		{
			this.Close();
		}
	}
}
Merci beaucoup pour votre aide qui me sera une fois de plus bénéfique

Ludo