小编Chr*_*ard的帖子

在 Citrix 会话中运行时,C# 用于确定客户端 IP 地址?

我目前使用 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)

c# citrix ip-address

3
推荐指数
1
解决办法
3979
查看次数

(新的Utf8Encoding())的序言是空的.GetPreamble() - 很奇怪

任何人都可以解释在新实例化的utf8编码上调用GetPreamble()与在Encoding类中提供的公共编码之间的区别吗?

byte[] p1 = Encoding.UTF8.GetPreamble();
byte[] p2 = new UTF8Encoding().GetPreamble();
Run Code Online (Sandbox Code Playgroud)

p1是正常的3字节utf-8前导码,但p2最终为空,这似乎非常错误.

.net c# encoding utf-8

1
推荐指数
1
解决办法
2485
查看次数

标签 统计

c# ×2

.net ×1

citrix ×1

encoding ×1

ip-address ×1

utf-8 ×1