منتدى ليبياأرس منتدى ليبياأرس منتدى ليبياأرس

العودة   منتدى ليبياأرس > الحـاســوب > لغات البرمجة

إضافة رد
 
أدوات الموضوع
قديم 2011-09-04, 07:51 AM   #1
عبسي الحمديني
مبرمج المستحيل
 
الصورة الرمزية عبسي الحمديني
 
تاريخ التسجيل: May 2010
الدولة: Libya
المشاركات: 2,924
معدل تقييم المستوى: 17
عبسي الحمديني على الطريق الصحيح لتعريف نفسه
Design كود لتغير الايبي


كود PHP:
Private Sub SetIP(ByVal IPAddress As StringByVal 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"), BooleanThen 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"objNewIPNothing)
            
objSetIP mgObject.InvokeMethod("SetGateways"objNewGateNothing)
        Catch 
ex As Exception
            MessageBox
.Show("An error occured: " ex.Message)
         
End Try
    
Next
End Sub
 
 Example Usage
SetIP
("192.168.1.230""255.255.255.0""192.168.1.51"
__________________

عبسي الحمديني غير متواجد حالياً   رد مع اقتباس
إضافة رد


تعليمات المشاركة
لا تستطيع إضافة مواضيع جديدة
لا تستطيع الرد على المواضيع
لا تستطيع إرفاق ملفات
لا تستطيع تعديل مشاركاتك

BB code is متاحة
كود [IMG] متاحة
كود HTML معطلة

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


الساعة الآن 09:24 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd