procedure TMainForm.FormCreate(Sender: TObject);
var PcName:Array[0..max_computername_length+1] of char;
size:dword;
begin
Size:=max_computername_length+1;
If GetComputerName(PcName,Size) then PC_Name:=StrPas(PCName) Else
PC_name:='Not Found';
end;
----- Original Message -----
From: "Roberto Freitas" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Thursday, May 04, 2006 7:55 PM
Subject: [delphi-en] Computer Name
Hello, I use this function to get computer name on Win 98:
function Computer_Name(CName: PChar): PChar;
var
Registro : TRegistry;
i : ShortInt;
S : String;
begin
result := CName;
Registro := TRegistry.Create;
try
Registro.RootKey := HKEY_LOCAL_MACHINE;
if Registro.OpenKey
('\System\CurrentControlSet\Services\VxD\VNETSUP', False) then
begin
S := Registro.ReadString('ComputerName');
if (Length(S) > 0) then
for i := 1 to Length(S) do
begin
CName^ := S[i];
Inc(CName);
end;
Registro.CloseKey;
end;
finally
Registro.Free;
end;
CName^ := #0;
end;
It works fine with Win 98.
What changes are necessary in order to work properly also with Win
2000 and Win XP?
How can I know what operational system is running on the computer?
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
SPONSORED LINKS
| C programming language | Computer programming languages | Java programming language |
| The c programming language | C programming language | Concept of programming language |
YAHOO! GROUPS LINKS
- Visit your group "delphi-en" on the web.
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.

