需要加入nb30单元function TStationInfo.GetHaha: WideString; //获取网卡地址
var
NCB:TNCB; // Netbios control block :NetBios控制块
AdapterStatus : TADAPTERSTATUS ; // Netbios adapter status :取网卡状态
LANAENUM : TLANAENUM ; // Netbios lana
cRC : Char ; // Netbios return code//NetBios返回值
intIdx : Integer ; // Temporary work value: 临时变量
strTemp : String ; // Temporary string: 临时变量
begin
// Initialize
Result := '' ; try
// Zero control blocl
ZeroMemory(@NCB,SizeOf(NCB)) ;
// Issue enum command
NCB.ncb_command := Chr(NCBENUM) ;
// Reissue enum command
NCB.ncb_buffer := @LANAENUM ;
NCB.ncb_length := SizeOf(LANAENUM) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Reset adapter
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBRESET) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Get adapter address
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBASTAT) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
StrPCopy(NCB.ncb_callname,'*') ;
NCB.ncb_buffer := @AdapterStatus ;
NCB.ncb_length := SizeOf(AdapterStatus) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Convert it to string
strTemp := '' ;
for intIdx := 0 to 5 do
strTemp := strTemp + IntToHex(Byte(AdapterStatus.adapter_address[intIdx]),2);
result:= Encrypt(strTemp);
except
result:= '';
raise EOleSysError.Create('Haha!',205,1);
end;
end ;function TStationInfo.GetWhat(why: Integer): Integer;
beginend;function TStationInfo.GetHello: WideString; //获取ip地址
var
ComputerName:array [0..MAX_COMPUTERNAME_LENGTH] of Char; //机器名字
nSize:DWORD; //字符缓冲区
MakeParam:WORD;
Data:WSADATA;
Hostent:PHostEnt;
retValue:string;
begin
result:= ''; try
nSize := SizeOf(ComputerName);
GetComputerName(ComputerName,nSize);
MakeParam := MAKEWORD( 2, 0 );
WSAStartup(MakeParam,Data);
ZeroMemory(@Hostent,SizeOf(Hostent)) ;
Hostent := GetHostByName(ComputerName); retValue := IntToStr(Ord((Hostent.h_addr_list)^[0]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[1]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[2]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[3]));
WSACleanup( );
result:= Encrypt(retValue);
except
result:='';
raise EOleSysError.Create ('Hello!',206,1);
end;
end;
var
NCB:TNCB; // Netbios control block :NetBios控制块
AdapterStatus : TADAPTERSTATUS ; // Netbios adapter status :取网卡状态
LANAENUM : TLANAENUM ; // Netbios lana
cRC : Char ; // Netbios return code//NetBios返回值
intIdx : Integer ; // Temporary work value: 临时变量
strTemp : String ; // Temporary string: 临时变量
begin
// Initialize
Result := '' ; try
// Zero control blocl
ZeroMemory(@NCB,SizeOf(NCB)) ;
// Issue enum command
NCB.ncb_command := Chr(NCBENUM) ;
// Reissue enum command
NCB.ncb_buffer := @LANAENUM ;
NCB.ncb_length := SizeOf(LANAENUM) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Reset adapter
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBRESET) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Get adapter address
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBASTAT) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
StrPCopy(NCB.ncb_callname,'*') ;
NCB.ncb_buffer := @AdapterStatus ;
NCB.ncb_length := SizeOf(AdapterStatus) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Convert it to string
strTemp := '' ;
for intIdx := 0 to 5 do
strTemp := strTemp + IntToHex(Byte(AdapterStatus.adapter_address[intIdx]),2);
result:= Encrypt(strTemp);
except
result:= '';
raise EOleSysError.Create('Haha!',205,1);
end;
end ;function TStationInfo.GetWhat(why: Integer): Integer;
beginend;function TStationInfo.GetHello: WideString; //获取ip地址
var
ComputerName:array [0..MAX_COMPUTERNAME_LENGTH] of Char; //机器名字
nSize:DWORD; //字符缓冲区
MakeParam:WORD;
Data:WSADATA;
Hostent:PHostEnt;
retValue:string;
begin
result:= ''; try
nSize := SizeOf(ComputerName);
GetComputerName(ComputerName,nSize);
MakeParam := MAKEWORD( 2, 0 );
WSAStartup(MakeParam,Data);
ZeroMemory(@Hostent,SizeOf(Hostent)) ;
Hostent := GetHostByName(ComputerName); retValue := IntToStr(Ord((Hostent.h_addr_list)^[0]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[1]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[2]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[3]));
WSACleanup( );
result:= Encrypt(retValue);
except
result:='';
raise EOleSysError.Create ('Hello!',206,1);
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 := '';
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;
var
NCB:TNCB; // Netbios control block :NetBios控制块
AdapterStatus : TADAPTERSTATUS ; // Netbios adapter status :取网卡状态
LANAENUM : TLANAENUM ; // Netbios lana
cRC : Char ; // Netbios return code//NetBios返回值
intIdx : Integer ; // Temporary work value: 临时变量
strTemp : String ; // Temporary string: 临时变量
begin
// Initialize
Result := '' ; try
// Zero control blocl
ZeroMemory(@NCB,SizeOf(NCB)) ;
// Issue enum command
NCB.ncb_command := Chr(NCBENUM) ;
// Reissue enum command
NCB.ncb_buffer := @LANAENUM ;
NCB.ncb_length := SizeOf(LANAENUM) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Reset adapter
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBRESET) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Get adapter address
ZeroMemory(@NCB,SizeOf(NCB)) ;
NCB.ncb_command := Chr(NCBASTAT) ;
NCB.ncb_lana_num := LANAENUM.lana[0] ;
StrPCopy(NCB.ncb_callname,'*') ;
NCB.ncb_buffer := @AdapterStatus ;
NCB.ncb_length := SizeOf(AdapterStatus) ;
cRC := NetBios(@NCB) ;
if Ord(cRC) <> 0 then exit ; // Convert it to string
strTemp := '' ;
for intIdx := 0 to 5 do
strTemp := strTemp + IntToHex(Byte(AdapterStatus.adapter_address[intIdx]),2);
result:= Encrypt(strTemp);
except
result:= '';
raise EOleSysError.Create('Haha!',205,1);
end;
end ;function TStationInfo.GetWhat(why: Integer): Integer;
beginend;function TStationInfo.GetHello: WideString; //获取ip地址
var
ComputerName:array [0..MAX_COMPUTERNAME_LENGTH] of Char; //机器名字
nSize:DWORD; //字符缓冲区
MakeParam:WORD;
Data:WSADATA;
Hostent:PHostEnt;
retValue:string;
begin
result:= ''; try
nSize := SizeOf(ComputerName);
GetComputerName(ComputerName,nSize);
MakeParam := MAKEWORD( 2, 0 );
WSAStartup(MakeParam,Data);
ZeroMemory(@Hostent,SizeOf(Hostent)) ;
Hostent := GetHostByName(ComputerName); retValue := IntToStr(Ord((Hostent.h_addr_list)^[0]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[1]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[2]))+'.';
retValue := retValue + IntToStr(Ord((Hostent.h_addr_list)^[3]));
WSACleanup( );
result:= Encrypt(retValue);
except
result:='';
raise EOleSysError.Create ('Hello!',206,1);
end;
end;