写成[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]就可以
因为如果不加CharSet.Unicode,会使用默认值Charset.Auto,导致中文解析失败
在.NET中使用DllImport时,若不指定CharSet为Unicode,可能会因默认的Charset.Auto导致中文参数解析错误。添加CharSet.Unicode参数确保正确处理中文字符。
写成[DllImport("kernel32", CharSet = CharSet.Unicode, SetLastError = true)]就可以
因为如果不加CharSet.Unicode,会使用默认值Charset.Auto,导致中文解析失败
4094
5109

被折叠的 条评论
为什么被折叠?
