blob: ebe7f942e478b3f59e28974d7006b4f2306962fc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
unit lws2tcpip;
{$mode delphi}
interface
uses
WinSock2;
const
ws2tcpip = 'ws2_32.dll';
AI_PASSIVE = $1;
AI_CANONNAME = $2;
AI_NUMERICHOST = $4;
type
LPADDRINFO = ^addrinfo;
addrinfo = record
ai_flags: Integer;
ai_family: Integer;
ai_socktype: Integer;
ai_protocol: Integer;
ai_addrlen: size_t;
ai_canonname: PChar;
ai_addr: PSockAddr;
ai_next: LPADDRINFO;
end;
TAddrInfo = addrinfo;
PAddrInfo = LPADDRINFO;
function getaddrinfo(nodename, servname: PChar; hints: PAddrInfo; var res: PAddrInfo): Integer; stdcall;
procedure freeaddrinfo(ai: PAddrInfo); stdcall;
implementation
uses
dynlibs;
type
TGetAddrInfoFunc = function (nodename, servname: PChar; hints: PAddrInfo; var res: PAddrInfo): Integer; stdcall;
TFreeAddrInfoProc = procedure (ai: PAddrInfo); stdcall;
var
_lib: TLibHandle;
_getaddrinfo: TGetAddrInfoFunc;
_freeaddrinfo: TFreeAddrInfoProc;
function getaddrinfo(nodename, servname: PChar; hints: PAddrInfo;
var res: PAddrInfo): Integer; stdcall;
begin
_getaddrinfo(nodename, servname, hints, res);
end;
procedure freeaddrinfo(ai: PAddrInfo); stdcall;
begin
end;
initialization
_lib := LoadLibrary(ws2tcpip);
_getaddrinfo := GetProcedureAddress(_lib, 'getaddrinfo');
_freeaddrinfo := GetProcedureAddress(_lib, 'freeaddrinfo');
finalization
UnloadLibrary(_lib);
end.
|