C#调用C++的dll,dllimport相对路径
public delegate int Compile(String command, StringBuilder inf);//编译
DllInvoke dll = new DllInvoke(Server.MapPath(@"~/Bin/Judge.dll"));
Compile compile = (Compile)dll.Invoke("Compile", typeof(Compile));
StringBuilder inf;
compile(@“gcc a.c -o a.exe“,inf); //这里就是调用我的DLL里定义的Compile函数
参照以上,改如何修改?
相对路径:~/Bin/MyDll.dll
MyDll.dll中的函数是:EncryptData(string pszSrcData, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szMD5Result)
若用绝对路径:[DllImport(@"F:\webgameNow\bin\MyDll.dll")]
public static extern void EncryptData(string pszSrcData, [MarshalAs(UnmanagedType.LPStr)] StringBuilder szMD5Result);可以实现。