我目前使用 WFAPI 从 C# 确定 Citrix 会话的客户端 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; …
Run Code Online (Sandbox Code Playgroud) 任何人都可以解释在新实例化的utf8编码上调用GetPreamble()与在Encoding类中提供的公共编码之间的区别吗?
byte[] p1 = Encoding.UTF8.GetPreamble();
byte[] p2 = new UTF8Encoding().GetPreamble();
Run Code Online (Sandbox Code Playgroud)
p1是正常的3字节utf-8前导码,但p2最终为空,这似乎非常错误.