यह जांचने के लिए कि क्या सर्वर पोर्ट पर सुन रहा है, आप Winsock ओएलई नियंत्रण
:
type
TSocketState =
(sckClosed, sckOpen, sckListening, sckConnectionPending, sckResolvingHost,
sckHostResolved, sckConnecting, sckConnected, sckClosing, sckError);
type
TMsg = record
hwnd: HWND;
message: UINT;
wParam: Longint;
lParam: Longint;
time: DWORD;
pt: TPoint;
end;
const
PM_REMOVE = 1;
function PeekMessage(var lpMsg: TMsg; hWnd: HWND; wMsgFilterMin, wMsgFilterMax,
wRemoveMsg: UINT): BOOL; external 'example@sqldat.com stdcall';
function TranslateMessage(const lpMsg: TMsg): BOOL;
external 'example@sqldat.com stdcall';
function DispatchMessage(const lpMsg: TMsg): Longint;
external 'example@sqldat.com stdcall';
procedure AppProcessMessage;
var
Msg: TMsg;
begin
while PeekMessage(Msg, 0, 0, 0, PM_REMOVE) do
begin
TranslateMessage(Msg);
DispatchMessage(Msg);
end;
end;
function CheckPort(Host: string; Port: Integer): Boolean;
var
Socket: Variant;
begin
Socket := CreateOleObject('MSWinsock.Winsock');
Socket.RemoteHost := Host;
Socket.RemotePort := Port;
Socket.Connect;
{ Winsock requires message pumping }
while not (Socket.State in [sckConnected, sckError]) do
begin
AppProcessMessage;
end;
Result := (Socket.State = sckConnected);
if Result then
begin
Log(Format('Port %d on %s is open', [Port, Host]));
end
else
begin
Log(Format('Port %d on %s is NOT open', [Port, Host]));
end;
Socket.Close;
end;
ध्यान दें कि Winsock नियंत्रण के लिए संदेश कतार पम्पिंग की आवश्यकता होती है। इसलिए उपयोगकर्ता को फ़ॉर्म के साथ खिलवाड़ करने से रोकने के लिए, आपको चेक चलाने से पहले विज़ार्ड को अक्षम करने की आवश्यकता हो सकती है।
श्रेय:AppProcessMessage इनोसेटअप UI को ब्लॉक किए बिना 7zip कैसे निष्पादित करें?