منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
(تم الحل) طلب كود تغيير ip الجهاز - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم اسئلة VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=183)
+--- الموضوع : (تم الحل) طلب كود تغيير ip الجهاز (/showthread.php?tid=4773)



(تم الحل) طلب كود تغيير ip الجهاز - Easy4ever - 01-10-12

السلام عليكم ورحمة الله وبركاته
أخواني
أريد كود يقوم بإضافة
IP في بروتوكول TCP/IPv4

حيث ان بدلا ما أدخل في محولات الأتصال واروح الخصائص وبعدين ادخل في خيارات TCP/IPv4 واضيف IP
خلاص من خلال هذا الكود أضيف IP إللي أبيه

وشكرا



(تم الحل) طلب كود تغيير ip الجهاز - amgadtamer - 02-10-12

مرفق مثال به المطلوب


(تم الحل) طلب كود تغيير ip الجهاز - Easy4ever - 02-10-12

أخي البرنامج لايعمل Sad

فقط يكتب ping ورقم الإيبي في مربع textbox بشكل مستمر
ولا يغير شيء

وجربت أفتحه كمسؤول نفس الحال



(تم الحل) طلب كود تغيير ip الجهاز - m.sami.ak - 02-10-12

بسم الله الرحمن الرحيم
استعمل الاجراء التالي

1) Project > Add Reference > System.Management option in the list.


2) Add 'Imports System.Management' (without the quotation) to the top of your code.

PHP كود :
''' <summary>
''' 
Sets the IP address of the local machine.
''' </summary>
''' 
<param name="IPAddress">The IP address to set the computer to</param>
''' <param name="SubnetMask">The subnet mask to set the computer to</param>
''' 
<param name="Gateway">The gateway to set the computer to</param>
''' <remarks>Adapted from code by Logu Krishnan at
''' 
http://www.codeproject.com/KB/system/cstcpipwmi.aspx
''' Requires a reference to the System.Management namespace</remarks>
Private Sub SetIP(ByVal IPAddress As String, ByVal SubnetMask As String, _
* * * * * * * * * ByVal Gateway As String)




* * Dim managementClass As New ManagementClass("Win32_NetworkAdapterConfiguration")
* * Dim mgObjCollection As ManagementObjectCollection = managementClass.GetInstances()




* * For Each mgObject As ManagementObject In mgObjCollection
* * * * If Not CType(mgObject("IPEnabled"), Boolean) Then Continue For




* * * * Try
* * * * * * Dim objNewIP As ManagementBaseObject = Nothing
* * * * * * Dim objSetIP As ManagementBaseObject = Nothing
* * * * * * Dim objNewGate As ManagementBaseObject = Nothing




* * * * * * objNewIP = mgObject.GetMethodParameters("EnableStatic")
* * * * * * objNewGate = mgObject.GetMethodParameters("SetGateways")




* * * * * * ' 
Set the default gateway (decided to declare and initialise
* * * * * * ' variables rather than attempting to initialize the array
* * * * * * ' 
while communicating with the WMI.
* * * * * * 
Dim tmpStrArray() As String = {Gateway}




* * * * * * 
objNewGate("DefaultIPGateway") = tmpStrArray
* * * * * * Dim tmpIntArray() As Integer = {1}
* * * * * * 
objNewGate("GatewayCostMetric") = tmpIntArray




* * * * * * ' Set the IP address and subnet.
* * * * * * tmpStrArray(0) = IPAddress
* * * * * * objNewIP("IPAddress") = tmpStrArray
* * * * * * tmpStrArray(0) = SubnetMask
* * * * * * objNewIP("SubnetMask") = tmpStrArray




* * * * * * objSetIP = mgObject.InvokeMethod("EnableStatic", objNewIP, Nothing)
* * * * * * objSetIP = mgObject.InvokeMethod("SetGateways", objNewGate, Nothing)
* * * * Catch ex As Exception
* * * * * * MessageBox.Show("An error occured: " + ex.Message)
* * * * End Try
* * Next
End Sub 


كود الاستدعاء
PHP كود :
' Example Usage
SetIP("192.168.1.230", "255.255.255.0", "192.168.1.51") 
ارفقت لك الكود في ملف نصي لان بعض الكلمات ممنوعة بالمنتدى
فتظهر لك (****)

تحياتي لك
ابو سامي




(تم الحل) طلب كود تغيير ip الجهاز - Easy4ever - 02-10-12

اشتغل كود الأخ M.Sami.AK

* ملاحظة يجب تشغيل البرنامج كمسؤول

هنااا
تسلموا على المساعدة جزاكم الله خير

~ تم الحل ~



(تم الحل) طلب كود تغيير ip الجهاز - m.sami.ak - 02-10-12

تم ايجاد الحل المناسب