Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [Code]
- const
- WINSOCK_2_2 = 514;
- INADDR_NONE = $FFFFFFFF;
- WSASYS_STATUS_LEN = 128;
- WSADESCRIPTION_LEN = 256;
- type
- u_long = DWORD;
- #ifndef UNICODE
- AnsiString = string;
- #endif
- TWSAData = record
- wVersion: Word;
- wHighVersion: Word;
- szDescription: array[0..WSADESCRIPTION_LEN] of AnsiChar;
- szSystemStatus: array[0..WSASYS_STATUS_LEN] of AnsiChar;
- iMaxSockets: Word;
- iMaxUdpDg: Word;
- lpVendorInfo: PAnsiChar;
- end;
- function WSAStartup(wVersionRequested: Word; var lpWSAData: TWSAData): Integer;
- external 'WSAStartup@ws2_32.dll stdcall';
- function WSACleanup: Integer;
- external 'WSACleanup@ws2_32.dll stdcall';
- function inet_addr(cp: AnsiString): DWORD;
- external 'inet_addr@ws2_32.dll stdcall';
- function IsValidIPv4(const Value: string): Boolean;
- var
- Data: TWSAData;
- begin
- Result := Value <> '';
- if Result then
- begin
- if WSAStartup(WINSOCK_2_2, Data) = 0 then
- begin
- Result := inet_addr(AnsiString(Value)) <> INADDR_NONE;
- WSACleanup;
- end
- else
- RaiseException('Winsock initialization failed!');
- end;
- end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement