很简单,但也搞得我很头大,高手请帮助我。 函数向前引用引起的问题:将LocalIP Function放在FormCreate前面就可以了。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 1.在窗體Form1的類聲明中加入function LocalIP : string;再在過程體中加入TForm1.或2.將function LocalIP : string;整個過程體放到procedure TForm1.FormCreate(Sender: TObject);與begin之間3.或如上面那位先生所說 改为如下:unit Unit2;interfaceusesWindows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Winsock, StdCtrls, ExtCtrls, Menus ,clipbrd;type TForm1 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end;var Form1: TForm1;function LocalIP : string;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);beginLabel1.Caption:='IP: '+LocalIP;//上面这句每次编译,结果总是如下的出错//[Error] Unit2.pas(27): Undeclared identifier: 'LocalIP'end;end.//IP函数function LocalIP : 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; cxgrid 求助 在线等待 delphi操作iis问题 我是初学者,请问有关在客户端改变查询条件问题。 怎样让程序第一次写注册表,以后可读可写 初学者简单问题,多谢 关于数据库选用的问题? 求助关于SERVICE_TABLE_ENTRY结构 delphi IDHTTP 如何POST这种数据 帮忙万分感谢! 怎么实现自动编号? 有关installshield和database的问题 内存数据怎么copy 你要是能帮我解决这个问题,分多多都给
或
2.將function LocalIP : string;整個過程體放到
procedure TForm1.FormCreate(Sender: TObject);與begin之間
3.或如上面那位先生所說
unit Unit2;interfaceuses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Winsock, StdCtrls, ExtCtrls, Menus ,clipbrd;
type
TForm1 = class(TForm)
Label1: TLabel;
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;function LocalIP : string;implementation{$R *.DFM}procedure TForm1.FormCreate(Sender: TObject);
begin
Label1.Caption:='IP: '+LocalIP;
//上面这句每次编译,结果总是如下的出错
//[Error] Unit2.pas(27): Undeclared identifier: 'LocalIP'end;end.//IP函数
function LocalIP : 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;