تقييم الموضوع :
  • 0 أصوات - بمعدل 0
  • 1
  • 2
  • 3
  • 4
  • 5
(تم الحل) طلب كود تغيير ip الجهاز
#1
السلام عليكم ورحمة الله وبركاته
أخواني
أريد كود يقوم بإضافة
IP في بروتوكول TCP/IPv4

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

وشكرا
Big Grin
<---------------------------------------------------------------->

}}}
تم الشكر بواسطة:
#2
مرفق مثال به المطلوب


الملفات المرفقة
.zip   restartmodem_2.zip (الحجم : 104.15 ك ب / التحميلات : 113)
}}}
تم الشكر بواسطة:
#3
أخي البرنامج لايعمل Sad

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

وجربت أفتحه كمسؤول نفس الحال
Big Grin
<---------------------------------------------------------------->

}}}
تم الشكر بواسطة:
#4
بسم الله الرحمن الرحيم
استعمل الاجراء التالي

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") 
ارفقت لك الكود في ملف نصي لان بعض الكلمات ممنوعة بالمنتدى
فتظهر لك (****)

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



الملفات المرفقة
.txt   Function.txt (الحجم : 2.25 ك ب / التحميلات : 106)
}}}
تم الشكر بواسطة:
#5
اشتغل كود الأخ M.Sami.AK

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

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

~ تم الحل ~
Big Grin
<---------------------------------------------------------------->

}}}
تم الشكر بواسطة:
#6
تم ايجاد الحل المناسب
}}}
تم الشكر بواسطة:



التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم