如何马歇​​尔LPCWSTR到字符串在C#中? [英] How to marshall a LPCWSTR to String in C#?

查看:230
本文介绍了如何马歇​​尔LPCWSTR到字符串在C#中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图定义一个P /下列方法

I'm trying to define a P/Invoke signature for the following method (defined in propsys.h)

PSSTDAPI PSRegisterPropertySchema(
    __in PCWSTR pszPath);



我见过的 WINNT.H PCWSTR 是一个别名 LPCWSTR

typedef __nullterminated CONST WCHAR *LPCWSTR, *PCWSTR;



以及 PSSTDAPI 是一个别名 HRESULT

那么应该如何在p /为 PSRegisterPropertySchema 方法?

So how should be the P/Invoke signature for the PSRegisterPropertySchema method?

推荐答案

设置字符集值<后code> CharSet.Unicode 它的工作。

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



没有specifing的字符集的函数返回 80070057 这是 E_INVALIDARG

这篇关于如何马歇​​尔LPCWSTR到字符串在C#中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆