Autor Beitrag
bbfan
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: Fr 20.04.07 10:30 
Hallo Leute!

Ich möchte gerne über eine Delphi (D7) Applciation den Namen meines PCs ändern.

Wie könnte ich das am gescheitesten machen?

Viele Grüße,
BBFAN
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 20.04.07 10:57 
Moin!

Oh Wunder: SetComputerName() ;)

Aber: Reboot! :mahn:

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: Fr 20.04.07 11:15 
nicht schlecht die idee, klappt aber nicht.

Auch nach Reboot, steht der alte PC Name drin.

Muss man noch was drumherum bauen?

Vielleicht:
HKEY_LOCAL_MACHINE,'System\CurrentControlSet\Control\ComputerName\ComputerName
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 20.04.07 11:35 
Moin!

Was sagt der RetCode der API-Funktion? Weiterhin: Adminrechte (war aber klar, oder?) ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: Fr 20.04.07 11:43 
Ja, habe Admin Rechte...

Benutze jetzt folgende Funktion (die auch nicht geht). ReturnCode ist TRUE, doch PC Name ist immer noch der alte.

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
function SetComputerNameX(AComputerName: string): Boolean;
var
  ComputerName: array[0..MAX_COMPUTERNAME_LENGTH + 1] of Char;
  Size: Cardinal;
begin
  StrPCopy(ComputerName, AComputerName);
  Result := Windows.SetComputerName(ComputerName);
end;
bbfan Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 164



BeitragVerfasst: Fr 20.04.07 11:55 
Hab es gelöst. Man muss diesen Befehl verwenden:

ausblenden Delphi-Quelltext
1:
SetComputerNameEx(ComputerNamePhysicalDnsHostname,'MEIN_NEUER_NAME');					


Weisst du zufällig noch den Befehl um die Beschreibung des PCs neu zu setzen?
Narses
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Administrator
Beiträge: 10185
Erhaltene Danke: 1261

W11x64
TP3 .. D7pro .. D10.2CE
BeitragVerfasst: Fr 20.04.07 12:07 
Moin!

user profile iconbbfan hat folgendes geschrieben:
Hab es gelöst. Man muss diesen Befehl verwenden:
ausblenden Delphi-Quelltext
1:
SetComputerNameEx(ComputerNamePhysicalDnsHostname,'MEIN_NEUER_NAME');					

Wenn das geht, dann geht auch SetComputerName... :? Zeig doch nochmal deinen Aufruf. :|

user profile iconbbfan hat folgendes geschrieben:
Weisst du zufällig noch den Befehl um die Beschreibung des PCs neu zu setzen?

Nicht auswendig, schon im MSDN geschaut? ;)

cu
Narses

_________________
There are 10 types of people - those who understand binary and those who don´t.