{"id":605,"date":"2008-05-16T04:16:03","date_gmt":"2008-05-16T04:16:03","guid":{"rendered":"http:\/\/6teen.ru\/?p=605"},"modified":"2008-05-16T04:16:03","modified_gmt":"2008-05-16T04:16:03","slug":"7220-2","status":"publish","type":"post","link":"http:\/\/pblog.ru\/lab\/?p=605","title":{"rendered":"\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442"},"content":{"rendered":"<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442<br \/>\n<!--more--><\/p>\n<pre class=\"alt2\" style=\"margin:0px; padding:6px; border:1px inset; width:580px; height:320px; overflow:auto\"><div>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442\n\nuses winsock;\n\n-------\n\nfunction IPAddrToName(IPAddr : String): String;\nvar\nSockAddrIn: TSockAddrIn;\nHostEnt: PHostEnt;\nWSAData: TWSAData;\nbegin\nWSAStartup($101, WSAData);\nSockAddrIn.sin_addr.s_addr:= inet_addr(PChar(IPAddr));\nHostEnt:= gethostbyaddr(@SockAddrIn.sin_addr.S_addr, 4, AF_INET);\nif HostEnt<>nil then\nbegin\nresult:=StrPas(Hostent^.h_name)\nend\nelse\nbegin\nresult:='';\nend;\n\n\/\/\u041f\u0440\u0438\u043c\u0435\u0440 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f:\n\nprocedure TForm1.Button1Click(Sender: TObject);\nbegin\nLabel1.Caption:=IPAddrToName(Edit1.Text);\nend;\n\n\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u043e \u0432 6.12.03, 09:10\n\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u0435 \u0438\u043c\u044f \u0432 IP \u0430\u0434\u0440\u0435\u0441.\n\n\u0410\u0432\u0442\u043e\u0440: Lutfi Baran\n\n\u041e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442, \u043a\u0430\u043a \u0432\u044b\u0447\u0438\u0441\u043b\u0438\u0442\u044c IP \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435 \u043f\u043e \u0435\u0433\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438.\n\n\u0421\u043e\u0432\u043c\u0435\u0441\u0442\u0438\u043c\u043e\u0441\u0442\u044c: Delphi 3.x (\u0438\u043b\u0438 \u0432\u044b\u0448\u0435)\n\n\u041e\u0431\u044a\u044f\u0432\u043b\u044f\u0435\u043c Winsock, \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432 \u0444\u0443\u043d\u043a\u0446\u0438\u0438\n............\n\nfunction HostToIP(Name: string; var Ip: string): Boolean;\nvar\nwsdata : TWSAData;\nhostName : array [0..255] of char;\nhostEnt : PHostEnt;\naddr : PChar;\nbegin\nWSAStartup ($0101, wsdata);\ntry\ngethostname (hostName, sizeof (hostName));\nStrPCopy(hostName, Name);\nhostEnt := gethostbyname (hostName);\nif Assigned (hostEnt) then\nif Assigned (hostEnt^.h_addr_list) then begin\naddr := hostEnt^.h_addr_list^;\nif Assigned (addr) then begin\nIP := Format ('%d.%d.%d.%d', [byte (addr [0]),\nbyte (addr [1]), byte (addr [2]), byte (addr [3])]);\nResult := True;\nend\nelse\nResult := False;\nend\nelse\nResult := False\nelse begin\nResult := False;\nend;\nfinally\nWSACleanup;\nend\nend;\n................................\n\n\u0412\u044b \u043c\u043e\u0436\u0435\u0442\u0435 \u0440\u0430\u0437\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u043d\u0430 \u0444\u043e\u0440\u043c\u0435 EditBox, \u041a\u043d\u043e\u043f\u043a\u0443 \u0438 Label \u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043a \u043a\u043d\u043e\u043f\u043a\u0435 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a \u0441\u043e\u0431\u044b\u0442\u0438\u044f OnClick:\n\nprocedure TForm1.Button1Click(Sender: TObject);\nvar\nIP: string;\nbegin\nif HostToIp(Edit1.Text, IP) then Label1.Caption := IP;\nend;\n<\/div><\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 IP-\u0430\u0434\u0440\u0435\u0441\u0430 \u043f\u043e \u0434\u043e\u043c\u0435\u043d\u043d\u043e\u043c\u0443 \u0438\u043c\u0435\u043d\u0438 \u0438 \u043d\u0430\u043e\u0431\u043e\u0440\u043e\u0442<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[448,457],"tags":[1149,1308,1465,1574],"_links":{"self":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/605"}],"collection":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=605"}],"version-history":[{"count":0,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=\/wp\/v2\/posts\/605\/revisions"}],"wp:attachment":[{"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=605"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=605"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/pblog.ru\/lab\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=605"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}