Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
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
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
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
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
OK merci beaucoup
Didier
"JB" <boisgontier@hotmail.com> a écrit dans le message de news:
1138647974.788062.240270@g49g2000cwa.googlegroups.com...
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
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