即時通訊目前使用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環境。 有沒有人有更好的方法來做到這一點?
還有誰知道如何確定過程是否實際上在思傑環境中運行?