I want to find out which ip can be remote. (remote desktop)
For example, I set a valid IP of my network into an edit box and the program says it can be remote or not.
I want to find out which ip can be remote. (remote desktop)
For example, I set a valid IP of my network into an edit box and the program says it can be remote or not.
Search a Remote Desktop component for Delphi and try to connect.
to determine if an ip address is a remote desktop server you can use WTSEnumerateServers
function.
follow these steps
WTSEnumerateServers
functionsee this sample, wich show how use the WTSEnumerateServers
function
uses
Classes,
Windows,
SysUtils;
type
PWTS_SERVER_INFO = ^WTS_SERVER_INFO;
_WTS_SERVER_INFO = packed record
pServerName:LPTSTR;
end;
WTS_SERVER_INFO = _WTS_SERVER_INFO;
WTS_SERVER_INFO_Array = Array [0..0] of WTS_SERVER_INFO;
PWTS_SERVER_INFO_Array =^WTS_SERVER_INFO_Array;
{$IFDEF UNICODE}
function WTSEnumerateServers( pDomainName: LPTSTR; Reserved: DWORD; Version: DWORD; ppServerInfo: PWTS_SERVER_INFO; pCount: PDWORD):BOOLEAN; stdcall; external 'wtsapi32.dll' name 'WTSEnumerateServersW';
{$ELSE}
function WTSEnumerateServers( pDomainName: LPTSTR; Reserved: DWORD; Version: DWORD; ppServerInfo: PWTS_SERVER_INFO; pCount: PDWORD):BOOLEAN; stdcall; external 'wtsapi32.dll' name 'WTSEnumerateServersA';
{$ENDIF}
procedure WTSFreeMemory(pMemory:Pointer);stdcall; external 'wtsapi32.dll' name 'WTSFreeMemory';
procedure GetRemoteDesktopsList(const Domain:PChar;const Servers:TStrings);
var
ppServerInfo : PWTS_SERVER_INFO_Array;//PWTS_SERVER_INFO;
pCount : DWORD;
i : integer;
begin
Servers.Clear;
ppServerInfo:=nil;
try
if WTSEnumerateServers(Domain,0,1,PWTS_SERVER_INFO(@ppServerInfo),@pCount) then
for i := 0 to pCount - 1 do
Servers.Add(ppServerInfo^[i].pServerName)
else
Raise Exception.Create(SysErrorMessage(GetLastError));
finally
if ppServerInfo<>nil then
WTSFreeMemory(ppServerInfo);
end;
end;
and then call like this
Servers:=TStringList.Create;
try
GetRemoteDesktops(nil,Servers); //using nil for the current domain.
//now process the list and do your stuff
finally
Servers.Free;
end;
It depends on what you are trying to accomplish: do you want to see if the server is up and running from within your network? If so try my Terminal Server Ping Tool. Else you can only check if something is listening on port 3389 eg with Indy.