?? record_define.pas
字號:
unit record_define;
interface
uses
Winsock,SysUtils;
const
buffer_max_size=256;
TEMP_SUMMIT=1;
PACKET_SUMMIT=2;
REMEDY_SECOND=10;
type
TCommBlock=record
data_long: Integer;
tcp_data:array [0..255] of char;
end;
{PClient= ^TClient;
TClient=record // Object holding data of client (see events)
DNS: String[20];
Connected,
LastAction:TDateTime;
Thread:Pointer;
end;}
procedure write_text(str:string);
function fetch_LocalIP(var inter_IP,outer_IP:string): boolean;
function char_to_str(data: array of char; data_long: integer;var str: string): boolean;
function insert_blank(var str: string): boolean;
function BCD_to_Hex(data: byte): byte;
implementation
procedure write_text(str:string);
var
log_file:textfile;
begin
assignfile(log_file,'log.txt');
append(log_file);
writeln(log_file,str);
writeln(log_file,'-----------------------------------------');
closefile(log_file);
end;
function fetch_LocalIP(var inter_IP,outer_IP:string): boolean;
type
TaPInAddr = array [0..10] of PInAddr;
PaPInAddr = ^TaPInAddr;
var
phe : PHostEnt;
pptr : PaPInAddr;
Buffer : array [0..63] of char;
I : Integer;
GInitData : TWSADATA;
temp:string;
begin
WSAStartup($101, GInitData);
GetHostName(Buffer, SizeOf(Buffer));
phe :=GetHostByName(buffer);
if phe = nil then Exit;
pptr := PaPInAddr(Phe^.h_addr_list);
if pptr^[0] <> nil then
inter_IP:=StrPas(inet_ntoa(pptr^[0]^))
else
inter_IP:='127.0.0.1';
if pptr^[1] <> nil then
outer_IP:=StrPas(inet_ntoa(pptr^[1]^))
else
outer_IP:=inter_IP;
WSACleanup;
end;
function char_to_str(data: array of char; data_long: integer;
var str: string): boolean;
var
i:integer;
begin
str:='';
for i:=0 to data_long-1 do
begin
str:=str+inttoHex(integer(data[i]),2);
end;
end;
function insert_blank(var str: string): boolean;
var
i,str_long:integer;
temp_str:string;
begin
temp_str:=str;
str_long:=length(str);
i:=3;
while(i<str_long) do
begin
if ((i mod 48)=0) then
begin
System.insert(' ', temp_str, i);
temp_str[i]:=#13;
end
else
System.insert(' ', temp_str, i);
i:=i+3;
str_long:=str_long+1;
end;
str_long:=length(temp_str);
i:=13;
while(i<str_long) do
begin
if temp_str[i-1]<>#13 then
begin
System.insert(' ', temp_str, i);
i:=i+3;
str_long:=str_long+3;
end;
i:=i+12;
end;
str:=temp_str;
end;
function BCD_to_Hex(data: byte): byte;
var
temp:byte;
begin
temp:=data div 16;
result:=temp*10+(data mod 16);
end;
end.
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -