0

我正在使用 VS 2012:

这是我的情况:

我正在用 Visual Basic 编写一些代码,调用我用 C++ 编写的 dll 函数(也使用 vs 2012 编写)。我的函数参数之一采用 wchar_t* 数据​​类型,因此我需要使用 StrPtr 相应地从 vb 格式化我的字符串。

这是我的问题:

Visual Basic 不将 StrPtr 识别为函数。我得到: 'StrPtr' 未声明。由于其保护级别,它可能无法访问。

这是什么意思?

4

2 回答 2

2

StrPtr is a VB6 function, it does not exist in VB.Net

VarPtr, VarPtrArray, VarPtrStringArray, ObjPtr and StrPtr were undocumented functions used to get the underlying memory address of variables. These functions are not supported in Visual Basic .NET.

The equivalent .Net Framework method for wide strings is Marshal.StringToHGlobalUni().

Although likely you should be using P/Invoke to call a C++ funciton in which case the marshaling of a String to wchar_t is handled automatically.

于 2013-09-29T03:20:59.767 回答
1

此关键字已从语言中删除:

VarPtr、VarPtrArray、VarPtrStringArray、ObjPtr 和 StrPtr 是用于获取变量底层内存地址的未记录函数。Visual Basic 2008 不支持这些函数。

于 2013-09-29T03:19:19.973 回答