1.对于.net或者com型的组件,直接添加引用即可. 2.对于标准的dll文件,利用DLLImport这个函数即可,如果要使用函数的别名,那么应该加入EntryPoint. 示例:一般可以封装成一个类,然后在其他类中引用即可. using System.Runtime.InteropServices; public class MyWin32Wrapper { [DllImport("User32.dll")] static public extern void Beep(int f
部分时候,我们需要自己封装一些小工具来简化我们的工作. 实验时,偶然发现Unity3d的console在双击进行debug信息的输出定位时,只能跟进到dll的上一层,因此我们可以将unity3d自带的Debug进行封装,以方便我们在游戏发布时对log信息的屏蔽. 代码如下: using UnityEngine; public class MyDebug { public static bool m_bStartTest = true; public static void Log(object
一.C#封装成DLL 1.在VS中创建项目选择类库,命名 myDll 2.建立好项目后自动生成的代码如下: 代码修改如下,添加自己要封装的C#代码,注意修饰符必须为public using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace myDLL { public class Class1 { //封装的DLL函数 public int add(int x, in