Registriert seit: 10. Okt 2006
Ort: 's-Hertogenbosch, Die Niederlande
222 Beiträge
RAD-Studio 2010 Arc
|
Re: WTSQuerySessionInformation IPv6 address
19. Nov 2007, 13:47
This is a helper function:
Delphi-Quellcode:
procedure TJwWTSSession.GetSessionInfoPtr( const WTSInfoClass: _WTS_INFO_CLASS;
var ABuffer: Pointer);
var dwBytesReturned: DWORD;
Res: Bool;
begin
Res :=
{$IFDEF UNICODE}
WTSQuerySessionInformationW(GetServerHandle, FSessionId, WTSInfoClass,
ABuffer, dwBytesReturned);
{$ELSE}
WTSQuerySessionInformationA(GetServerHandle, FSessionId, WTSInfoClass,
ABuffer, dwBytesReturned);
{$ENDIF}
// function always returns an error 997: overlapped IO on session 0
if ( not Res) and (FSessionId <> 0) then
begin
raise EJwsclWinCallFailedException.CreateFmtWinCall(RsWinCallFailed,
' WTSQuerySessionInformation', ClassName, RSUNTerminalServer, 0, True,
' WTSQuerySessionInformation', [' WTSQuerySessionInformation']);
end;
end;
And this is where the ClientAddress is retrieved, as you can see I'm dumping this to a .bin file now (which is what I pasted above)
Delphi-Quellcode:
function TJwWTSSession.GetClientAddress: TJwString;
var ClientAddressPtr: PWtsClientAddress;
begin
ZeroMemory(ClientAddressPtr, SizeOf(TWtsClientAddress));
GetSessionInfoPtr(WTSClientAddress, Pointer(ClientAddressPtr));
{Note that the first byte of the IP address returned in the ppBuffer
parameter will be located at an offset of 2 bytes from the start of
the Address member of the returned WTS_CLIENT_ADDRESS structure.}
case ClientAddressPtr^.AddressFamily of
AF_INET:
Result := Format(' %d.%d.%d.%d', [ClientAddressPtr^.Address[2],
ClientAddressPtr^.Address[3], ClientAddressPtr^.Address[4],
ClientAddressPtr^.Address[5]]);
AF_INET6:
// Result := 'IPv6 address not yet supported';
begin
with TFileStream.Create(' C:\temp\AF_INET6.bin', fmCreate) do
try
Write(ClientAddressPtr^, SizeOf(TWtsClientAddress));
finally
Free;
end;
end;
AF_IPX:
Result := ' IPX is not supported';
AF_NETBIOS:
Result := ' NETBIOS is not supported';
AF_UNSPEC:
Result := ' ';
end;
WTSFreeMemory(ClientAddressPtr);
end;
|
|
Zitat
|