PC Review


Reply
Thread Tools Rate Thread

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

 
 
Dr. StrangeDub
Guest
Posts: n/a
 
      19th Feb 2004
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\Control\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


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      19th Feb 2004

>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.
 
Reply With Quote
 
Dr. StrangeDub
Guest
Posts: n/a
 
      19th Feb 2004

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
<(E-Mail Removed)> 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\Control\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
>


 
Reply With Quote
 
Mattias Sjögren
Guest
Posts: n/a
 
      20th Feb 2004
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.
 
Reply With Quote
 
Dr. StrangeDub
Guest
Posts: n/a
 
      20th Feb 2004
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
<(E-Mail Removed)> 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


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Computer name different with NetBIOS computer name =?Utf-8?B?a3lzaW93?= Microsoft Windows 2000 0 24th Mar 2005 10:13 AM
Computer browsing, NETBIOS =?Utf-8?B?RG9uIEpvbmVz?= Microsoft Windows 2000 Networking 3 31st Jan 2005 09:49 PM
NetBios computer names and SP2 SalamOnAltern Windows XP Setup 1 6th Nov 2004 04:08 PM
NetBIOS computer name Scott Freeman Windows XP Customization 3 19th Sep 2003 06:38 PM
Changing the NetBIOS computer name Scott Freeman Windows XP Customization 3 17th Sep 2003 11:36 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:45 PM.