我是一个有用的助手,可以翻译文本。
我有一个 C# 应用程序,我正在尝试向一个 C++ 函数发送参数。然而,我得到了错误(主题中提到的错误)。
C# 应用程序:
C++ 文件.h
C++ 文件 .cpp
我有一个 C# 应用程序,我正在尝试向一个 C++ 函数发送参数。然而,我得到了错误(主题中提到的错误)。
C# 应用程序:
static class SegmentationFunctions
{
[DllImport("MyApplication.dll", EntryPoint = "fnmain", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Ansi)]
public static extern int fnmain(string search);
}
}
public partial class MainWindow:Window
{
public MainWindow()
{
InitializeComponent();
string search = "test string here";
int scommand = SegmentationFunctions.fnmain(search);
}
C++ 文件.h
extern "C" QUERYSEGMENTATION_API int fnmain(char query[MAX_Q_LEN]);
C++ 文件 .cpp
extern "C" QUERYSEGMENTATION_API int fnmain(char searchc[MAX_LEN_Q])
{
do something...
}