2

c#のコードでホスト名を変更したい。OSはxpです。

ありがとう。

4

2 に答える 2

2
ManagementClass mComputerSystem = new ManagementClass("Win32_ComputerSystem");
ManagementBaseObject outParams;
ManagementBaseObject objNewComputerName = mComputerSystem.GetMethodParameters("Rename");
objNewComputerName["Name"] = "NEWNAMEHERE";
outParams = mComputerSystem.InvokeMethod("Rename", objNewComputerName, null);
于 2011-02-13T16:26:50.517 に答える
1

これらのレジストリ キーを編集し、再起動します。Computer Browser と Server and Client サービスを再起動するだけでうまくいくかもしれませんが、私はそれを疑っています。

HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname
HKLM\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname
HKLM\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName
于 2011-02-13T16:31:40.720 に答える