| Olyv | Salut
 je fais appel à une fonction WMI (EnableStatic) faisant partie de 'Win32_NetworkAdapterConfiguration'.
 
 Cette fonction permet de changer l'adresse IP de la machine sur l'adaptateur réseau 0.
 
 Voici la signature de la fonction:
 
 | Code : 
 uint32 EnableStatic(  string IPAddress[],  string SubnetMask[]);ParametersIPAddress    [in] Lists all the static IP addresses for the current network adapter. Example: 155.34.22.0.SubnetMask    [in] Subnet masks that complement the values in the IPAddress parameter. Example: 255.255.0.0.
 | 
 
 Voici mon code faisant appel à la fonction:
 
 
 | Code : 
 var  WService: SWbemServices;  WClass: SWbemObject;  WMethod: SWbemMethod;  WInParameters: SWbemObject;  WInParameteIPAddress: SWbemProperty;  WInParameteSubnetMask: SWbemProperty;  Parametre1, Parametre2: OleVariant;  WResult: SWbemObject;  WReturnValue: OleVariant;begin  WService := SWbemLocator.ConnectServer('.', 'ROOT\CIMV2', '', '', '', '', wbemConnectFlagUseMaxWait, nil);  WClass   := WService.Get('Win32_NetworkAdapterConfiguration', 0, nil);  WMethod := WClass.Methods_.Item('EnableStatic', 0);  WInParameters := WMethod.InParameters.SpawnInstance_(0);  WInParameteIPAddress  := WInParameters.Properties_.Item('IPAddress', 0);  Parametre1 := '192.168.51.47';  WInParameteIPAddress.Set_Value(Parametre1);  Parametre1 := WInParameteIPAddress.Name;  WInParameteSubnetMask := WInParameters.Properties_.Item('SubnetMask', 0);  Parametre2 := '255.255.255.0';  WInParameteSubnetMask.Set_Value(Parametre2);  Parametre2 := WInParameteSubnetMask.Name;  WResult := WClass.ExecMethod_('EnableStatic', WInParameters, wbemFlagReturnWhenComplete, nil);  WReturnValue := WResult.Properties_.Item('ReturnValue', 0);end;
 | 
 
 Le probème qui se pose c'est lorsque ExecMethod s'exécute, j'ai une exception qui me dit 'Paramètres de méthode non valide.'
 
 
  pourtant mes paramètres sont corrects.....   
 si quelqu'un a une idée !!!
   Message édité par Olyv le 30-09-2005 à 11:01:28
 |