unit sy102Unit1;
interface
uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, Borland.Vcl.StdCtrls, System.ComponentModel,WinSock;
type
  TForm1 = class(TForm)
    Label1: TLabel;
    Label2: TLabel;
    Edit1: TEdit;
    Edit2: TEdit;
    Button1: TButton;
    Button2: TButton;
    Button3: TButton;
    function GetHostName:String;
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
    procedure Button3Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;
var
  Form1: TForm1;
implementation
{$R *.nfm}
 function TForm1.GetHostName:String;
  var
    ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;
    Size: Cardinal;
  begin
    result:='';
    Size := MAX_COMPUTERNAME_LENGTH+1;
    GetComputerName(ComputerName, Size);
    Result:=StrPas(ComputerName);
  end;
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text:=GetHostName;
  Edit2.Text:=DateTimeToStr(Now);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
  Edit1.Text:='';
  Edit2.Text:='';
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
    application.Terminate;
end;
end.
这是使用DELPHI8获取计算机名称的程序,但不知为什么,在USER中不能直接通过添加WINSOCK来实现GETCOMPUTERNAME()函数的调用,在DELPHI7可以?请指教,谢谢!
[此贴子已经被作者于2006-4-26 18:43:22编辑过]

											