Forum |  HardWare.fr | News | Articles | PC | S'identifier | S'inscrire | Shop Recherche
1416 connectés 

  FORUM HardWare.fr
  Programmation

  trouver le nom du pc??

 


 Mot :   Pseudo :  
 
Bas de page
Auteur Sujet :

trouver le nom du pc??

n°19868
bowfinger
Posté le 22-03-2001 à 13:56:01  profilanswer
 

peux t'on me dire comment je peux faire pour retrouver le nom d'un ordinateur connecter sous NT4 dans un reseau en utilisant Visual Basic?

mood
Publicité
Posté le 22-03-2001 à 13:56:01  profilanswer
 

n°19932
zop
1 world, 1 web, 1 Windows
Posté le 22-03-2001 à 17:06:07  profilanswer
 

bowfinger a écrit a écrit :

peux t'on me dire comment je peux faire pour retrouver le nom d'un ordinateur connecter sous NT4 dans un reseau en utilisant Visual Basic?




 
Tu veux le nom du PC sur lequel tourne le soft ? c'est bien çà ?
En C il y a la fonction 'GetComputerName'

n°19937
bowfinger
Posté le 22-03-2001 à 17:11:14  profilanswer
 

ok et en vb??

n°19945
zop
1 world, 1 web, 1 Windows
Posté le 22-03-2001 à 17:25:04  profilanswer
 

Je ne connais pas le Vb mais j'ai fait une recherche dans MSDN :
"Tip 179: Retrieving the Computer Name
December 5, 1995
 
Abstract
This article explains how you can use the Microsoft® Windows® GetComputerName function to retrieve the computer name.
 
Using the GetComputerName Function
When you initially install the Microsoft® Windows® operating system on your computer, a default name is assigned to your computer. This name is initialized when you start your computer. The actual name is stored in the registration database (registry).
 
You can use the Windows application programming interface (API) GetComputerName function in your Microsoft® Visual Basic® application to retrieve the name assigned to your computer. To use this function, include the following Declare statement in your project:
 
Private Declare Function GetComputerName Lib "kernel32" Alias  
   "GetComputerNameA" (ByVal sBuffer As String, lSize As Long)  
   As Long
 
The GetComputerName function requires two arguments. The first argument, sBuffer, is the buffer that will hold the computer name after the function is executed. The size of the buffer should be large enough to hold the entire name. The second argument, lSize, must be initialized to the size of sBuffer.
 
After you have executed the GetComputerName function, the lSize variable will be set to a count of the actual number of characters stored in the sBuffer string. This count value does not include the terminating NULL character.
 
Example Program
This program shows how to retrieve the name assigned to a computer.  
 
Create a new project in Visual Basic. Form1 is created by default.
 
 
Add the following Declare statement to the General Declarations section of Form1 (note that this Declare statement must be typed as a single line of code):
Private Declare Function GetComputerName Lib "kernel32" Alias  
   "GetComputerNameA" (ByVal sBuffer As String, lSize As Long) As Long
 
Add a Command Button control to Form1. Command1 is created by default.
 
 
Add the following code to the Click event for Command1:
Private Sub Command1_Click()
    Dim PCName As String
    Dim P As Long
 
    P = NameOfPC(PCName)
    text1.Text = PCName
End Sub
 
Add a Text Box control to Form1. Text1 is created by default.
 
 
Create a new function called NameOfPC. Add the following code to this function:
Function NameOfPC(MachineName As String) As Long
 
    Dim NameSize As Long
    Dim X As Long
 
    MachineName = Space$(16)
    NameSize = Len(MachineName)
    X = GetComputerName(MachineName, NameSize)
End Function
 
Run the example program by pressing f5. Click the Command Button control. The name assigned to the computer appears in the Text Box control.
"
 
 
Voilou

n°19948
bowfinger
Posté le 22-03-2001 à 17:28:56  profilanswer
 

merci


Aller à :
Ajouter une réponse
  FORUM HardWare.fr
  Programmation

  trouver le nom du pc??

 

Sujets relatifs
trouver des fuites de memoires[Flash 5] Où trouver des sons?
où trouver le moteur de quake 3 ?Microstation et MDL : où trouver de la documentation ?
Microstation et MDL : où trouver de la documentationOU TROUVER DES OUTILS
Au secours, où trouver un compilateur gratos pour du QBasic, vite![JAVA ou JAVASCRIPT] Où trouver un moteur de recherche pour site ?
Ou trouver f95 un compilateur gratuit de fortran?Ou trouver Kit flash???
Plus de sujets relatifs à : trouver le nom du pc??


Copyright © 1997-2022 Hardware.fr SARL (Signaler un contenu illicite / Données personnelles) / Groupe LDLC / Shop HFR