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

منتدى ليبياأرس (http://www.libyars.com/lrs/index.php)
-   لغات البرمجة (http://www.libyars.com/lrs/forumdisplay.php?f=37)
-   -   كود لتغير الايبي (http://www.libyars.com/lrs/showthread.php?t=4286)

عبسي الحمديني 2011-09-04 07:51 AM

كود لتغير الايبي
 

كود 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"



الساعة الآن 12:35 AM.

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