Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2003, 03:09 PM
mbranco mbranco is offline
Senior Member
 
Join Date: Jan 2001
Posts: 164
Default IP Number

How could i determinate ip number?

Thank's in advance

MB
Reply With Quote
  #2  
Old 07-03-2003, 03:19 PM
jamiguel77 jamiguel77 is offline
Senior Member
 
Join Date: Jan 2002
Posts: 1,155
Send a message via MSN to jamiguel77 Send a message via Yahoo to jamiguel77
Default RE: IP Number

test with these function:


function GetIPFromHost(var HostName, IPaddr, WSAErr: string): Boolean;
//--------------------------------------------------------------------
//------------HOW CAN CALL IT-----------------------------------------
// var Host,Ip,Err:String;
// if GetIPFromHost(Host, IP, Err) then begin
// Edit1.Text := Host;
// Edit2.Text := IP;
// end
// else
// MessageDlg(Err, mtError, [mbOk], 0);
type
Name = array[0..100] of Char;
PName = ^Name;
var
HEnt: pHostEnt;
HName: PName;
WSAData: TWSAData;
i: Integer;
begin
Result := False;
if WSAStartup($0101, WSAData) <> 0 then begin
WSAErr := 'Winsock is not responding."';
Exit;
end;
IPaddr := '';
New(HName);
if GetHostName(HName^, SizeOf(Name)) = 0 then
begin
HostName := StrPas(HName^);
HEnt := GetHostByName(HName^);
for i := 0 to HEnt^.h_length - 1 do
IPaddr :=
Concat(IPaddr,
IntToStr(Ord(HEnt^.h_addr_list^[i])) + '.');
SetLength(IPaddr, Length(IPaddr) - 1);
Result := True;
end
else begin
case WSAGetLastError of
WSANOTINITIALISED:WSAErr:='WSANotInitialised';
WSAENETDOWN :WSAErr:='WSAENetDown';
WSAEINPROGRESS :WSAErr:='WSAEInProgress';
end;
end;
Dispose(HName);
WSACleanup;
end;


other way:
http://groups.google.com/groups?q=GET%2Bip%2Bdelphi&hl=es&lr=&ie=UTF-8&oe=UTF-8&selm=3a098080%241_1%40dnews&rnum=1



Accept if help you thanks
Reply With Quote
  #3  
Old 07-03-2003, 03:20 PM
jamiguel77 jamiguel77 is offline
Senior Member
 
Join Date: Jan 2002
Posts: 1,155
Send a message via MSN to jamiguel77 Send a message via Yahoo to jamiguel77
Default RE: IP Number

test with these function:


function GetIPFromHost(var HostName, IPaddr, WSAErr: string): Boolean;
//--------------------------------------------------------------------
//------------HOW CAN CALL IT-----------------------------------------
// var Host,Ip,Err:String;
// if GetIPFromHost(Host, IP, Err) then begin
// Edit1.Text := Host;
// Edit2.Text := IP;
// end
// else
// MessageDlg(Err, mtError, [mbOk], 0);
type
Name = array[0..100] of Char;
PName = ^Name;
var
HEnt: pHostEnt;
HName: PName;
WSAData: TWSAData;
i: Integer;
begin
Result := False;
if WSAStartup($0101, WSAData) <> 0 then begin
WSAErr := 'Winsock is not responding."';
Exit;
end;
IPaddr := '';
New(HName);
if GetHostName(HName^, SizeOf(Name)) = 0 then
begin
HostName := StrPas(HName^);
HEnt := GetHostByName(HName^);
for i := 0 to HEnt^.h_length - 1 do
IPaddr :=
Concat(IPaddr,
IntToStr(Ord(HEnt^.h_addr_list^[i])) + '.');
SetLength(IPaddr, Length(IPaddr) - 1);
Result := True;
end
else begin
case WSAGetLastError of
WSANOTINITIALISED:WSAErr:='WSANotInitialised';
WSAENETDOWN :WSAErr:='WSAENetDown';
WSAEINPROGRESS :WSAErr:='WSAEInProgress';
end;
end;
Dispose(HName);
WSACleanup;
end;


other way:
http://groups.google.com/groups?q=GET%2Bip%2Bdelphi&hl=es&lr=&ie=UTF-8&oe=UTF-8&selm=3a098080%241_1%40dnews&rnum=1



Accept if help you thanks
Reply With Quote
  #4  
Old 07-03-2003, 05:19 PM
naughtyboy naughtyboy is offline
Junior Member
 
Join Date: Jun 2003
Posts: 22
Default RE: IP Number

try the following what i did for a friend on delphi32.com

uses ComCtrls;

var
ipEdit: HWND;
ipAddress: integer;

procedure TForm1.Button1Click(Sender: TObject);
begin
InitCommonControl(ICC_INTERNET_CLASSES);
ipEdit := CreateWindow(WC_IPADDRESS,nil,WS_CHILD or WS_VISIBLE,10,50,130,23,self.Handle,0,hinstance,ni l);
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
sendmessage(ipEdit,IPM_GETADDRESS,0,longint(@ipAdd ress));
if ipAddress <> 0 then
begin
Edit1.Text := IntToStr(FIRST_IPADDRESS(ipAddress))+'.'+IntToStr( SECOND_IPADDRESS(ipAddress))+'.'+IntToStr(THIRD_IP ADDRESS(ipAddress))+'.'+IntToStr(FOURTH_IPADDRESS( ipAddress));
end;

end;

maybe it is what you want!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 10:07 AM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2014, vBulletin Solutions, Inc.