function GetIpAddress: string;
var
wVersionRequested: WORD;
wsaData: TWSAData;
p: PHostEnt;
s: array[0..128] of Char;
begin
wVersionRequested := MAKEWORD(1, 1);
WSAStartup(wVersionRequested, wsaData);
try
GetHostName(@s, 128);
p := GetHostByName(@s);
{Get the IpAddress}
// Result := StrPas(iNet_ntoa(PInAddr(p^.h_addr_list^)^));
finally
WSACleanup
end
end;function GetTheComputerName: string;
var
ComputerName: array [0..MAX_COMPUTERNAME_LENGTH] of Char;
nSize: DWORD;
begin
nSize := MAX_COMPUTERNAME_LENGTH;
FillChar(ComputerName, MAX_COMPUTERNAME_LENGTH, 0);
GetComputerName(ComputerName, nSize);
Result := ComputerName
end;
var
wVersionRequested: WORD;
wsaData: TWSAData;
p: PHostEnt;
s: array[0..128] of Char;
begin
wVersionRequested := MAKEWORD(1, 1);
WSAStartup(wVersionRequested, wsaData);
try
GetHostName(@s, 128);
p := GetHostByName(@s);
{Get the IpAddress}
// Result := StrPas(iNet_ntoa(PInAddr(p^.h_addr_list^)^));
finally
WSACleanup
end
end;function GetTheComputerName: string;
var
ComputerName: array [0..MAX_COMPUTERNAME_LENGTH] of Char;
nSize: DWORD;
begin
nSize := MAX_COMPUTERNAME_LENGTH;
FillChar(ComputerName, MAX_COMPUTERNAME_LENGTH, 0);
GetComputerName(ComputerName, nSize);
Result := ComputerName
end;
解决方案 »
- 江湖告急---关于DELPHI使用SQLConnection查询MYSQL的问题
- 有谁用过delphi7的installshield!!!!请指教啊!
- 哪位大侠做过关于GPS的工程?
- 用d7下的tcpclient编写的client端程序在win98下可以正常工作,为什么到了pwin97或win95下却不能正常工作?
- 按条件执行触发器
- 急!求 Delphi打印报表代码!
- 关于treeview的问题
- 问大家一个问题:高手请近来!
- Delphi菜单控件。
- 如何获取当前dbgrid中某一行的记录,并复制到另外一个窗口的几个dbedit上???
- 怎样获得一个硬盘的序列号,请附详细的原代码
- 关于MDI窗体的一个问题
function GetIpAddress: string;
var
wVersionRequested: WORD;
wsaData: TWSAData;
p: PHostEnt;
s: array[0..128] of Char;
begin
wVersionRequested := MAKEWORD(1, 1);
WSAStartup(wVersionRequested, wsaData);
try
GetHostName(@s, 128);
p := GetHostByName(@s);
{Get the IpAddress}
Result := StrPas(iNet_ntoa(PInAddr(p^.h_addr_list^)^));
finally
WSACleanup
end
end;
CString m_hostname,str;
if( gethostname(szhostname, 128) == 0 )
{
struct hostent * phost;
int i;
phost = gethostbyname(szhostname);
m_hostname=szhostname;
i=0;
int j;
int h_length=4;
for( j = 0; j<h_length; j++ )
{
CString addr;
if( j > 0 )
str += ".";
addr.Format("%u", (unsigned int)((unsigned char*)phost->h_addr_list[i])[j]);
str += addr;
}
}
str就是地址