OVH Cloud OVH Cloud

Adresse IP

2 réponses
Avatar
Didier Novarin
Bonsoir
est-il possible d'avoir une procédure qui donne l'adresse IP ainsi que le
nom de la machine ?
Je vous remercie
Didier

2 réponses

Avatar
JB
Bonjour,

Dans un module:

Option Explicit
'-- Appels d'API pour obtenir le nom d'ordinateur
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Declare Function wu_GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long

Function GetComputerName() As Variant
Dim strComputerName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Créer le tampon.
strComputerName = String$(255, 0)
lngLength = 255
'-- Effectuer l'appel.
lngResult = wu_GetComputerName(strComputerName, lngLength)
'-- Nettoyer et affecter la valeur.
GetComputerName = Left(strComputerName, InStr(1, strComputerName,
Chr(0)) - 1)
End Function


Sub Essai
x= GetComputerName()
End sub

Cordialement JB
Avatar
Didier Novarin
OK merci beaucoup
Didier

"JB" a écrit dans le message de news:

Bonjour,

Dans un module:

Option Explicit
'-- Appels d'API pour obtenir le nom d'ordinateur
Declare Function wu_GetUserName Lib "advapi32.dll" Alias _
"GetUserNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long
Declare Function wu_GetComputerName Lib "kernel32" Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) _
As Long

Function GetComputerName() As Variant
Dim strComputerName As String
Dim lngLength As Long
Dim lngResult As Long
'-- Créer le tampon.
strComputerName = String$(255, 0)
lngLength = 255
'-- Effectuer l'appel.
lngResult = wu_GetComputerName(strComputerName, lngLength)
'-- Nettoyer et affecter la valeur.
GetComputerName = Left(strComputerName, InStr(1, strComputerName,
Chr(0)) - 1)
End Function


Sub Essai
x= GetComputerName()
End sub

Cordialement JB