获取计算机名称

function GetComputerName:String; //获取计算机名称
//引用winsock
var
wVersionRequested : WORD;
wsaData : TWSAData;
p : PHostEnt; s : array[0..128] of char;
begin
try
wVersionRequested := MAKEWORD(1, 1); //创建 WinSock
WSAStartup(wVersionRequested, wsaData); //创建 WinSock
GetHostName(@s,128);
p:=GetHostByName(@s);
Result:=p^.h_Name;
finally
WSACleanup; //释放 WinSock
end;
end;

原文地址:https://www.cnblogs.com/semth/p/8412531.html