在Delphi中获取本地计算机名称的最佳方法是什么 [英] What's the best method for getting the local computer name in Delphi
本文介绍了在Delphi中获取本地计算机名称的最佳方法是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
该代码必须与D2007和D2009兼容.
The code needs to be compatible with D2007 and D2009.
我的回答:感谢所有回答的人,我已经离开了:
My Answer: Thanks to everyone who answered, I've gone with:
function ComputerName : String;
var
buffer: array[0..255] of char;
size: dword;
begin
size := 256;
if GetComputerName(buffer, size) then
Result := buffer
else
Result := ''
end;
推荐答案
Windows API GetComputerName 应该可以.它在windows.pas中定义.
The Windows API GetComputerName should work. It is defined in windows.pas.
这篇关于在Delphi中获取本地计算机名称的最佳方法是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文