Autor Beitrag
neo
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: Fr 21.03.03 18:24 
Hallo!

Weiß wer von euch wie ich den Computer Name auslesen kann?

Danke!


Moderiert von user profile iconraziel: Topic aus Internet / Netzwerk verschoben am Fr 31.08.2007 um 18:30
Ex0rzist
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starofftopic star
Beiträge: 550

Win XP Prof.
Mandrake 10.0

D6
BeitragVerfasst: Fr 21.03.03 18:55 
Hallo,

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
function GetComputerNetName: string;
var
  buffer: array[0..255of char;
  size: dword;
begin
  size := 256;
  if GetComputerName(buffer, size) then
    Result := buffer
  else
    Result := '';
end;

_________________
If accidentally read, induce vomitting.
delphiDeveloper
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 48



BeitragVerfasst: Fr 21.03.03 18:57 
Titel: RechnerName ermitteln
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function GetRechnerName: string;
var
  len: DWORD;
begin
  len := MAX_COMPUTERNAME_LENGTH + 1;
  SetLength(result, len);
  if not Windows.GetComputerName(PChar(result), len) then
    RaiseLastWin32Error;
  SetLength(result, len);
end//function
neo Threadstarter
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic star
Beiträge: 179



BeitragVerfasst: Fr 21.03.03 20:44 
Titel: RE:
danke!
Dietmar1961
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 18



BeitragVerfasst: So 15.01.06 14:10 
Titel: Re: RechnerName ermitteln .... Noobfrage
Welche Unit muss ich einbinden, damit dieser Code unter VCL .NET funktioniert?
Kriege da immer 'ungültige Typumwandlung'??

Danke



user profile icondelphiDeveloper hat folgendes geschrieben:
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
function GetRechnerName: string;
var
  len: DWORD;
begin
  len := MAX_COMPUTERNAME_LENGTH + 1;
  SetLength(result, len);
  if not Windows.GetComputerName(PChar(result), len) then
    RaiseLastWin32Error;
  SetLength(result, len);
end//function
Fighter#1
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 787

Win XP, Ubuntu 8.04
Turbo Delphi 2006, Delphi 2005 Pe, Delphi 5 Pe, Netbeans 6.1, Eclipse, Microsoft VisualC#, Dev C++, PHP, HTML, CSS
BeitragVerfasst: So 15.01.06 14:37 
Was hat das in der Rubrik Internet / Netzwerk zu tun????
@Admins Bitte Verschieben

_________________
Wer andere beherrscht ist stark,
wer sich selbst beherrscht ist mächtig. Lao Tse
mexx2k
ontopic starontopic starontopic starontopic starontopic starontopic starhalf ontopic starofftopic star
Beiträge: 60



BeitragVerfasst: Fr 31.08.07 18:23 
muss ich da noch irgendwelche uses einbinden?

ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
procedure TForm1.Button1Click(Sender: TObject);
begin
  lbShowText.Caption := GetRechnerName;
end;

function TForm1.GetRechnerName: string;
var
  len: DWORD;
begin
  len := MAX_COMPUTERNAME_LENGTH + 1;
  SetLength(result, len);
  if not Windows.GetComputerName(PChar(result), len) then
    RaiseLastWin32Error;
  SetLength(result, len);
end;


ich bekomm hier immer den Fehler: Ungültige Typumwandlung in der Zeile 12:
ausblenden Delphi-Quelltext
1:
if not Windows.GetComputerName(PChar(result), len) then					
#Crasher
ontopic starontopic starontopic starontopic starontopic starontopic starontopic starontopic star
Beiträge: 23

Win 95, Win 98, Win NT, Win XP (used), Win Vista
D3, D4, D6, D7, D2005, BDS2006 Arch. UPD2
BeitragVerfasst: Fr 31.08.07 18:46 
ausblenden Delphi-Quelltext
1:
2:
3:
4:
5:
var
  MyComputerName: String;
begin
  MyComputerName := GetEnvironmentVariable('ComputerName');
end;


- Crasher