gpt4 book ai didi

c# - 在 C# 中使用 C++ 库

转载 作者:行者123 更新时间:2023-11-28 01:08:41 27 4
gpt4 key购买 nike

我正在自己做一个项目,因为性能很重要,我想在 C++ 上编写部分代码,并想从 C# 调用 C++ 代码。我将编写 C++ 库并想编写一个 C# 包装器,我该怎么做?你有什么建议我应该从哪里开始学习吗? [任何网站、任何链接、任何书籍]

谢谢!

最佳答案

例子:

window :

[DllImport("User32.dll")]
public static extern void SetWindowText(int h, String s);



Linux:

[System.Runtime.InteropServices.DllImport("/root/Desktop/q3noclient/libnoclient.so")]
static extern int DisconnectClient (string strServerIP, int iServerPort, string strClientIP, int iClientPort);



C#:

[DllImport("Comdlg32.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern bool GetSaveFileName(ref OPENFILENAME lpofn);



VB.NET:

<DllImport("Comdlg32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
Private Shared Function GetSaveFileName(ByRef lpofn As OPENFILENAME) As Boolean
End Function

关于c# - 在 C# 中使用 C++ 库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4772119/

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