begin
winexec('ipconfig',sw_show);
end;我想点一下按钮来查看我自己的ip地址,可是它一闪就过去了,请问如何办?
winexec('ipconfig',sw_show);
end;我想点一下按钮来查看我自己的ip地址,可是它一闪就过去了,请问如何办?
解决方案 »
- Delphi6中如何使用Dictionary?
- 我想动态生成多个控件,应该怎么实现?
- 急啊!sql数据库调用使条件语句无效
- 为什么呢
- 关于日期时间控件DateTimePicker使用的问题
- 如何得到OUTLOOK中的联系人地址
- clientsocket问题!
- SetActiveWindow在DELPHI6中起作用吗?
- 一次Show出所有Form!!!!!!!!!!
- function Execute(const SQL: String; Params: TParams = nil; Cache: Boolean
- 这是一个用户修改日志的图片,请问怎样做这个摸块
- 怎样制作仿XP的菜单?????散分!!!!
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;
WinSock;function GetLocalIP:string;
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;
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, WinSock, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
function GetLocalIP:string;implementation{$R *.dfm}
function GetLocalIP:string;
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;procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(GetLocalIP);
end;end.