OVH Cloud OVH Cloud

recuperer le nom du pc

5 réponses
Avatar
steph
est il possible en vb de r=E9cup=E9rer les informations=20
concernant l'ordinateur surtout le nom de l'ordinateur ?
Et comment ?

Merci

5 réponses

Avatar
Jessy Sempere [MVP]
Bonjour

Essais ceci :

PC =Environ("ComputerName")

--
@+
Jessy Sempere - Access MVP

------------------------------------
Site @ccess : http://access.jessy.free.fr/
Pour l'efficacité de tous :
http://users.skynet.be/mpfa/
------------------------------------
"steph" a écrit dans le message news:
2093701c4591b$ee366db0$
est il possible en vb de récupérer les informations
concernant l'ordinateur surtout le nom de l'ordinateur ?
Et comment ?

Merci
Avatar
ng
Salut,

Regarde du coté de GetComputerName() :


Private Const MAX_COMPUTERNAME_LENGTH As Long = 31
Private Declare Function GetComputerNameAPI Lib "kernel32" Alias
"GetComputerNameA" (ByVal lpBuffer As String, nSize As Long) As Long

Private Sub Form_Load()
Debug.Print GetComputerName
End Sub


Public Function GetComputerName() As String
Dim strBuffer As String, lStrLen As Long
lStrLen = MAX_COMPUTERNAME_LENGTH + 1
strBuffer = String$(lStrLen, vbNullChar)
Call GetComputerNameAPI(strBuffer, lStrLen)
GetComputerName = Left$(strBuffer, lStrLen)
strBuffer = ""
End Function


--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



steph a écrit :

est il possible en vb de récupérer les informations
concernant l'ordinateur surtout le nom de l'ordinateur ?
Et comment ?

Merci


Avatar
steph
ca marche !

merci beaucoup.
Avatar
PC =Environ("ComputerName")

et ca suffit !

merci quand meme
Avatar
ng
Salut,

Dans ce cas préfère utiliser Environ$() qui renvoie directement un string :

Dim strName As String
strName = Environ$("ComputerName")

Mais personnellement je préfère utiliser les APIs, accordant une confiance
limitée aux variables d'environnement...

--
Nicolas G.
FAQ VB : http://faq.vb.free.fr
API Guide : http://www.allapi.net
Google Groups : http://groups.google.fr/
MZ-Tools : http://www.mztools.com/
http://apisvb.europe.webmatrixhosting.net/



a
écrit :

PC =Environ("ComputerName")

et ca suffit !

merci quand meme