我正在使用RobertGiesecke的UnmanagedExports
我想导出DllMain入口点。
下面是我尝试过的
[DllExport("DllMain", CallingConvention.StdCall)]
public static bool DllMain(IntPtr hModule, uint dwReason, byte[] lpReserved)
{
// I Write a text to file here
return true;
}然后我调用LoadLibrary,但是什么也没有发生。有什么解决方案吗?
发布于 2016-10-20 00:53:26
万岁,我找到了一种使用静态构造函数的方法。
只需将包含导出的类设为静态,然后添加静态方法。
public static class Class1
{
static Class1()
{
Console.WriteLine("DLL MAIN (Only DLL_PROCESS_ATTACH) :D");
}
[DllExport("AddFunc", CallingConvention.Cdecl)]
public static int AddFunc(int a, int b)
{
return a + b + 1;
}
}调用AddFunc时,程序先调用Class1(仅一次),下一次调用AddFunc
不管怎么说,对于DLL_PROCESS_DETACH?
https://stackoverflow.com/questions/39933033
复制相似问题