473,468 Members | 1,369 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to change Computer Name -- not just NetBIOS Computer Name

Leaving network identification/DNS out of the picture, how does one
change the name of a computer in a local Workgroup (in C#)?

I implemented the SetComputerName() API call and that only seems to
change the NetBIOS Computer Name. I've verified that the underlying
registry key value that gets changed is:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contro l\ComputerName\ComputerName\ComputerName

Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?

Any help here greatly appreciated -- I'm under the gun on this one...

Michael Rose
-Unisys Corp
Jul 21 '05 #1
4 14266
Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?


SetComputerNameEx ?

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2

OK, thanks to Mattias I believe the API I want to use is
SetComputerNameEx. Now I just need to know how to invoke this from
C#. That is, does anyone know the P/Invoke definition for importing
this? Here's what I have for SetComputerName:
// PInvoke signature for SetComputerName in Kernel32.DLL
[DllImport("kernel32.dll")]
static extern bool SetComputerName(string lpComputerName);

I need the analogous PInvoke signature for SetComputerNameEx.

-Michael Rose

On Thu, 19 Feb 2004 13:19:44 -0600, Dr. StrangeDub
<st********@yahoo.com> wrote:
Leaving network identification/DNS out of the picture, how does one
change the name of a computer in a local Workgroup (in C#)?

I implemented the SetComputerName() API call and that only seems to
change the NetBIOS Computer Name. I've verified that the underlying
registry key value that gets changed is:

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Contr ol\ComputerName\ComputerName\ComputerName

Is there a recommended API (via Active Directory or WMI or Win32) for
finishing the job and getting the local Computer Name changed?

Any help here greatly appreciated -- I'm under the gun on this one...

Michael Rose
-Unisys Corp


Jul 21 '05 #3
Michael,
That is, does anyone know the P/Invoke definition for importing
this?


[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern bool SetComputerNameEx(COMPUTER_NAME_FORMAT NameType,
string lpBuffer);

enum COMPUTER_NAME_FORMAT
{
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
}

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #4
Hey, thanks again Mattias.....Glad to see that the P/Invoke signature
I ended up implementing (after a co-worker found the info) matches
exactly with what you entered.

Thanks again,
-Michael Rose
Unisys Corp

On Fri, 20 Feb 2004 01:05:26 +0100, Mattias Sjögren
<ma********************@mvps.org> wrote:
Michael,
That is, does anyone know the P/Invoke definition for importing
this?


[DllImport("kernel32.dll", CharSet=CharSet.Auto)]
static extern bool SetComputerNameEx(COMPUTER_NAME_FORMAT NameType,
string lpBuffer);

enum COMPUTER_NAME_FORMAT
{
ComputerNameNetBIOS,
ComputerNameDnsHostname,
ComputerNameDnsDomain,
ComputerNameDnsFullyQualified,
ComputerNamePhysicalNetBIOS,
ComputerNamePhysicalDnsHostname,
ComputerNamePhysicalDnsDomain,
ComputerNamePhysicalDnsFullyQualified,
}

Mattias


Jul 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: memememe | last post by:
I want to modify the computer name (the one used on netbios) before the configuration is read by netbios. I alreayd have a service that does this and I have created dependencies on this server for...
3
by: Vangelis | last post by:
Hi, I'm currently successfully retrieving the list of computers connected on the differents domains of our network via the System.DirectoryServices.DirectoryEntry class. What I'd like to have...
1
by: Hakki | last post by:
We need to resolve with which computer my computer is communicating. We write a sniffer that gets pakets and so we resolve ip addresses and now we need to get their domain names. I think we need...
4
by: Dr. StrangeDub | last post by:
Leaving network identification/DNS out of the picture, how does one change the name of a computer in a local Workgroup (in C#)? I implemented the SetComputerName() API call and that only seems to...
2
by: XiScO | last post by:
hi! I'm trying to get some info from other computers, I make ping to test that are powered on, then want to get netbios name and MAC. I get the dns name and get only first part as netbios...
2
by: martin lanny | last post by:
Simple network scanner is a part of my dotnet solution. It pings ip addresses in a selected network range and gives me the response time for each computer it finds. Anyhow, I would need to...
6
by: DevX | last post by:
Hello, I have a big intranet that I run with IIS 6.0. I need to log the client's machine names, and I found on the web istruction on how to use REMOTE_HOST server variable while enabling...
4
by: madankarmukta | last post by:
HI, I want to set my computername to be greate than 15 bytes.How can i do that since when i set the name greter that 15 bytes it's give me message that "The NetBIOS name of the computer is...
5
by: Steve McKewen | last post by:
I am working on Windows Mobile 6 with VS2005. I want my mobile devices to connect to a shared folder on a PC in an isolated network environment. I don't have a server or router in the network,...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.