gpt4 book ai didi

c# - 如何在 C# 中将 LPCWSTR 编码为字符串?

转载 作者:太空狗 更新时间:2023-10-29 22:55:43 25 4
gpt4 key购买 nike

我正在尝试为以下方法定义一个 P/Invoke 签名(在 propsys.h 中定义)

PSSTDAPI PSRegisterPropertySchema(
__in PCWSTR pszPath);

我在 WinNT.h 上看到 PCWSTRLPCWSTR 的别名

typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;

PSSTDAPIHRESULT 的别名

PSRegisterPropertySchema 方法的 P/Invoke 签名应该如何设置?

最佳答案

在将 CharSet 值设置为 CharSet.Unicode 后,它起作用了。

[DllImport("Propsys.dll", CharSet=CharSet.Unicode)]
static internal extern int PSRegisterPropertySchema(String pszPath);

在没有指定 CharSet 的情况下,该函数返回 0x80070057,即 E_INVALIDARG

关于c# - 如何在 C# 中将 LPCWSTR 编码为字符串?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2969654/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com