我想找出哪个ip可以远程。 (远程桌面)
例如,我将网络的有效IP设置为编辑框,程序说它可以是远程的。
答案 0 :(得分:4)
确定IP地址是否是远程桌面服务器,您可以使用WTSEnumerateServers
功能。
按照以下步骤操作
WTSEnumerateServers
函数请参阅此示例,其中显示了如何使用WTSEnumerateServers
函数
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;
然后像这样打电话
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;
答案 1 :(得分:0)
在远程桌面组件中搜索Delphi并尝试连接。
答案 2 :(得分:0)
这取决于您要完成的任务:您是否想要查看服务器是否已在您的网络中启动并运行?如果有,请尝试我的Terminal Server Ping Tool。 否则,您只能检查某些东西是否正在侦听3389端口,例如使用Indy。