如题
解决方案 »
- 如何在TChart中动态加入series?谢谢。
- ReceiveBuf???
- 小问题,解决即刻给分。
- 关于F1book的用法
- 关于报表控件
- 急急急!!!怎樣才能使ADO連接DSN成功,在線等待
- 下载delphi 6.0 中文版
- 爱迪尔门锁调用DLL如何连接数据库
- 我用ADO连接一Access数据库,当把表中记录删完后关闭程序出错。WHY?
- 在Delphi中怎样直接调用win32 API函数来创建窗口
- 麻烦各位告诉告诉俺Window Stations and Desktops里的一大堆函数都是干什么用的,谢谢。
- SOS! 关于ReportBuilder的TppDBPipeline和TppReport的问题,不知各位是如何处理的?
var
WSAData: TWSAData;
HostEnt: PHostEnt;
begin
{ no error checking...}
WSAStartup(2, WSAData);
SetLength(Name, 255);
Gethostname(PChar(Name), 255);
SetLength(Name, StrLen(PChar(Name)));
HostEnt := gethostbyname(PChar(Name));
with HostEnt^ do
Address := Format('%d.%d.%d.%d',[
Byte(h_addr^[0]),
Byte(h_addr^[1]),
Byte(h_addr^[2]),
Byte(h_addr^[3])]);
WSACleanup;
end;
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls,Winsock;type
TFormMain = class(TForm)
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
EditPresentation: TEdit;
EditResult: TEdit;
edtHost: TEdit;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
FormMain: TFormMain;implementation{$R *.DFM}procedure TFormMain.FormCreate(Sender: TObject);
Var
WSAData:TWSAData;
begin
//initiates use of WS2_32.DLL
if (WSAStartup(MAKEWORD(2,0),WSAData)<>0) then
raise Exception.Create('Winsock Version Error');
end;procedure TFormMain.FormDestroy(Sender: TObject);
begin
WSACleanUP;
end;
procedure TFormMain.Button1Click(Sender: TObject);
var
Host: pHostent;
ConsultResult:String;
Err:Integer;
begin
Try
Host := GetHostByName(PChar(EditPresentation.Text));
Except
Err:=WSAGetLastError();
EditResult.Text:='Error Code:'+InttoStr(Err);
Exit;
end;
if Host=NIL then
begin
EditResult.Text:='Host does not exist';
exit;
end;
ConsultResult:=Copy(Host.h_addr^,0,4);
EditResult.Text:=Format('%d.%d.%d.%d',
[ord(ConsultResult[1]),
ord(ConsultResult[2]),
ord(ConsultResult[3]),
ord(ConsultResult[4])]);
edtHost.Text:=Host.h_name;
end;end.
type
TaPInAddr = Array[0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe: PHostEnt;
pptr: PaPInAddr;
Buffer: Array[0..63] of Char;
I: Integer;
GInitData: TWSAData;
begin
WSAStartup($101, GInitData);
Result:=TStringList.Create;
Result.Clear;
GetHostName(Buffer, SizeOf(Buffer));
phe := GetHostByName(buffer);
if phe = nil then
begin
Exit;
end;
pPtr := PaPInAddr(phe^.h_addr_list);
I := 0;
while pPtr^[I] <> nil do
begin
Result.Add(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
memo1.Lines:=GetIps;
end;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
begin
WSAStartup($101, GInitData);
Result := '';
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
I := 0;
while pptr^[I] <> nil do begin
result:=StrPas(inet_ntoa(pptr^[I]^));
Inc(I);
end;
WSACleanup;
end;