function GetComputerNameEx: string; //获取本机名称
var
ComputerName: PChar;
size: DWord;
begin
GetMem(ComputerName, 255);
size := 255;
// 获取计算机名称
if GetComputerName(ComputerName, size) = False then
begin
result := '';
FreeMem(ComputerName);
Exit;
end;
result := ComputerName;
FreeMem(ComputerName);
end;
本文介绍了一个使用Pascal语言编写的简单函数,该函数用于获取运行系统的计算机名称。通过分配内存并调用系统API来实现这一目标。
357

被折叠的 条评论
为什么被折叠?



