![]() |
|
#16
|
||||
|
||||
![]() Я проверял, вполне работоспособный код.
Код:
unit Unit13; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm13 = class(TForm) Label1: TLabel; procedure FormCreate(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form13: TForm13; implementation {$R *.dfm} uses WinSock; function GetLocalIP: String; const WSVer = $101; var wsaData: TWSAData; P: PHostEnt; Buf: array [0..127] of Char; begin Result := ''; if WSAStartup(WSVer, wsaData) = 0 then begin if GetHostName(@Buf, 128) = 0 then begin P := GetHostByName(@Buf); if P <> nil then Result := iNet_ntoa(PInAddr(p^.h_addr_list^)^); end; WSACleanup; end; end; procedure TForm13.FormCreate(Sender: TObject); begin Label1.Caption := GetLocalIP end; end. Код:
object Form13: TForm13 Left = 0 Top = 0 Caption = 'Form13' ClientHeight = 302 ClientWidth = 635 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object Label1: TLabel Left = 16 Top = 24 Width = 31 Height = 13 Caption = 'Label1' end end Это тоже неработает? Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |