cs_CanisLupus
Messages postés
3757
Date d'inscription
mardi 23 septembre 2003
Statut
Membre
Dernière intervention
13 mars 2006
20
14 juin 2004 à 15:46
Bon, il y a un autre moyen, écrire directement dans la registry. Je te donne le code mais fais attention si tu es en réseau avec des relations d'approbation ou autres. Ta machine risue de ne plus être reconnue. G testé, ça marche sauf que dans ma boite, la machine ne redémarre plus car elle est connue par ce nom d'un serveur de sécurité.
Donc f8 au démarrage et démarrer avec dernière config correcte connue pour rétablir.
Private Const HKEY_LOCAL_MACHINE = &H80000002
Private Const REG_SZ As Long = 1
Private Declare Function RegCloseKey Lib "advapi32.dll" (ByVal hKey As Long) As Long
Private Declare Function RegCreateKey Lib "advapi32.dll" Alias "RegCreateKeyA" (ByVal hKey As Long, ByVal lpSubKey As String, phkResult As Long) As Long
Private Declare Function RegSetValueEx Lib "advapi32.dll" Alias "RegSetValueExA" (ByVal hKey As Long, ByVal lpValueName As String, ByVal Reserved As Long, ByVal dwType As Long, lpData As Any, ByVal cbData As Long) As Long
Private Sub Command1_Click()
Inscription_Base_Registre
End Sub
Sub Inscription_Base_Registre()
Dim strPath As String
Dim strValue As String
Dim NewName As String
NewName = InputBox("Entrez le nouveau nom de la machine.")
strPath = "System\CurrentControlSet\Control\Computername\ComputerName"
strValue = "ComputerName"
SaveString HKEY_LOCAL_MACHINE, strPath, strValue, NewName
'strPath = "System\CurrentControlSet\Control\Computername\ActiveComputerName"
strValue = "ComputerName"
SaveString HKEY_LOCAL_MACHINE, strPath, strValue, NewName
End Sub
Public Sub SaveString(hKey As Long, strPath As String, strValue As String, strdata As String)
Dim Keyhand As Long, r As Long
r = RegCreateKey(hKey, strPath, Keyhand)
r = RegSetValueEx(Keyhand, strValue, 0, REG_SZ, ByVal strdata, Len(strdata))
r = RegCloseKey(Keyhand)
End Sub
Cordialement
CanisLupus