本机的机器名(20分)

H

henry3

Unregistered / Unconfirmed
GUEST, unregistred user!
请问:delphi中有什么函数可以得到本机的机器名吗?
 
gethostname
 
GetComputerName
 
API函数有!
 
Help里找不到GetComputerName??
是什么API函数呢?
在delphi里如何使用Api函数呢?
 
it is in Delphi help->windows sdk
procedure TForm1.Button1Click(Sender: Tobject);
var
ComputerName: array[0..MAX_COMPUTERNAME_LENGTH+1] of char;

Size: Integer;

begin
Size := MAX_COMPUTERNAME_LENGTH+1;
if GetComputerName(ComputerName, Size) then
Edit1.Text := StrPas(Computername)
else
Showmessage('Computer Name Not Found');
end;
 
谢谢!
但是“Types of actual and formal var parameters must be identical”??
 
you can declare
size:word;
I think problem is here
 
大家的讨论十分热烈,对于此问题guo_qpeter的回答我曾经试过,可以行得通,但不知还有其它方法吗?
 
你试过?行的通?
我这里为什么不行?还是出错:
Types of actual and formal var parameters must be identical
我已经改为 size: Word 了。
 
知道了,不是 Word,应为: aSize: cardinal;
 
谢谢大家,成了。
 
顶部