问题解决: function GetClientIP: String; var i: DWORD; buf: PWTSClientAddress; j: integer; str: string; begin if WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientAddress, pointer(buf), i) then if buf.AddressFamily <> AF_UNSPEC then begin for j := 2 to 5 do str := str + IntToStr(buf.AddRess[j]) + '.'; Result := Copy(str, 1, Length(str) - 1); end else Result := '127.0.0.1'; end;
C:\WINDOWS\System32\svchost.exe -k termsvcs
服务,然后查询连接到它的ms-wbt-server协议的TCP端口(端口号好像是3389),看有哪些IP就可以了吧
function GetClientIP: String;
var
i: DWORD;
buf: PWTSClientAddress;
j: integer;
str: string;
begin
if WTSQuerySessionInformation(WTS_CURRENT_SERVER_HANDLE, WTS_CURRENT_SESSION, WTSClientAddress, pointer(buf), i) then
if buf.AddressFamily <> AF_UNSPEC then
begin
for j := 2 to 5 do
str := str + IntToStr(buf.AddRess[j]) + '.';
Result := Copy(str, 1, Length(str) - 1);
end
else
Result := '127.0.0.1';
end;