如何将 vb.net 字符串转换为 PCHAR

how to convert a vb.net string into PCHAR?

本文关键字:转换 PCHAR 字符串 net vb      更新时间:2023-10-16

net 应用程序和 c++ dll

在我的程序中,我正在从 dll 调用一个需要 3 个 PCHAR 参数的函数

Public Shared Function myfunction(ByVal dllname As String, ByVal gamename As String, ByVal dllpath As String)
End Function

但是 dll 期待 PCHAR 参数,但我不认为这是 vb.net 的一个选项?

任何帮助将不胜感激

我假设本机函数只是读取String / PCHAR值,而不是尝试修改它们。 如果是这样,请尝试以下操作

<DllImport("TheDllName")> _
Public Shared Function TheDllFunctionName( _
  <In> ByVal dllName As String, _
  <In> ByVal gameName As String, _
  <In> ByVal dllPath As String) As Integer
End Function

您需要将DllName替换为本机 DLL 的名称,TheDllFunctionName替换为 C/C++ 函数的名称