即时通讯目前使用WFAPI确定从C#当在citrix会话中运行时,C#用于确定客户端IP地址?
[StructLayout(LayoutKind.Sequential)]
internal struct WF_CLIENT_ADDRESS {
public int AddressFamily;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 20)]
public byte[] Address;
}
[DllImport("WFAPI.dll", EntryPoint = "WFFreeMemory")]
private static extern void WFFreeMemory(IntPtr pMemory);
[DllImport("WFAPI.dll", EntryPoint = "WFQuerySessionInformationA")]
private static extern bool WFQuerySessionInformation(IntPtr hServer,
int iSessionId, int infotype, out IntPtr ppBuffer, out int pBytesReturned);
const int ClientAddress = 14;
const int CurrentSession = -1;
static readonly IntPtr CurrentServer = IntPtr.Zero;
public static string GetClientAddress() {
IntPtr addr;
int returned;
bool ok = WFQuerySessionInformation(CurrentServer, CurrentSession,
ClientAddress, out addr, out returned);
if (!ok) return null;
WF_CLIENT_ADDRESS obj = new WF_CLIENT_ADDRESS();
obj = (WF_CLIENT_ADDRESS)Marshal.PtrToStructure(addr, obj.GetType());
string clientAdress =
obj.Address[2] + "." + obj.Address[3] + "." +
obj.Address[4] + "." + obj.Address[5];
WFFreeMemory(addr);
return clientAdress;
}
Citrix会话的客户端IP地址WFAPI.DLL/WFAPI64.DLL似乎可以在我有机会获得Citrix环境。 有没有人有更好的方法来做到这一点?
还有谁知道如何确定过程是否实际上在思杰环境中运行?