How do I change the computer name

G

greg chu

Hi, I tried to use

Private Declare Function SetComputerName Lib "kernel32" Alias
"SetComputerNameA" (ByVal lpComputerName As String) As Long

SetComputerName(newname)

newname is the name I want to change to.
But after I reboot the windows 2000 prof. the computer name remained
the same.

Any ideas?

Thanks!

Greg
 
H

Herfried K. Wagner [MVP]

greg chu said:
Private Declare Function SetComputerName Lib "kernel32" Alias
"SetComputerNameA" (ByVal lpComputerName As String) As Long

SetComputerName(newname)

newname is the name I want to change to.
But after I reboot the windows 2000 prof. the computer name remained
the same.

Use this declare instead:

\\\
Private Declare Auto Function SetComputerName Lib "kernel32.dll" ( _
ByVal lpComputerName As String _
) As Boolean
..
..
..
Dim Success As Boolean = SetComputerName("Bla")
///

First, check the return value. If it is 'False', then check the computer
name (see documentation for information about valid computer names).
Second, note that the name change will take place after a restart.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top