C#怎么调用MFC dll??? 怎么引用MFC dll工程生成的dll,在C#中 using不了 ?指点下高手 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 类似于这样[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]private static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile); 标准的`DLL就是这么调用的,没有其他方法了USING那个只用于.NET下生成的装配件 [DllImport("Kernel32.dll")] internal static extern IntPtr LoadLibrary(string file); [DllImport("Kernel32.dll")] internal static extern IntPtr GetProcAddress( IntPtr module, [MarshalAs(UnmanagedType.LPStr)] string procName); internal delegate bool TestFunction(param1,param2...); string path = dll的路径; // 自己添加代码 IntPtr dllHandle = Win32Api.LoadLibrary(path); if (dllHandle == (IntPtr)null) { return ; } IntPtr proc = GetProcAddress(dllHandle, "TestFunction"); if (proc != (IntPtr)null) { TestFunction func = (TestFunction)Marshal.GetDelegateForFunctionPointer(proc, typeof(TestFunction)); } else { return; } 这样 func函数 跟dll中的TestFunction是一个功能. 通过使用func 来代替使用dll中的TestFunction. 把.dll文件添加引用了试试.. C#中 窗体与类 C#操作ORACLE[大家来帮忙!!] SOCKET传输中的中文转换问题 求教。。。关于listview 如何实例阻塞试循环检测节省资源 怎样将一组NumericUpDown放入Control[]数组 关于C#从数据库中写入Word文档---有点急 如何判断目标窗口是否关闭? 为什么Char和Char[]没有ToUpper/ToLower这样的函数,String才有呢? 结个鸟贴!!老是脚本运行错误,根本无法结。散分 在ascx中读取index.aspx的对象 visual studio 2005怎么这么慢啊
[DllImport("kernel32.dll", CharSet=CharSet.Auto, SetLastError=true)]
private static extern SafeFileHandle CreateFile(string lpFileName, int dwDesiredAccess, FileShare dwShareMode, SECURITY_ATTRIBUTES securityAttrs, FileMode dwCreationDisposition, int dwFlagsAndAttributes, IntPtr hTemplateFile);
USING那个只用于.NET下生成的装配件
internal static extern IntPtr LoadLibrary(string file); [DllImport("Kernel32.dll")]
internal static extern IntPtr GetProcAddress(
IntPtr module,
[MarshalAs(UnmanagedType.LPStr)] string procName);
internal delegate bool TestFunction(param1,param2...); string path = dll的路径; // 自己添加代码
IntPtr dllHandle = Win32Api.LoadLibrary(path);
if (dllHandle == (IntPtr)null) { return ; } IntPtr proc = GetProcAddress(dllHandle, "TestFunction");
if (proc != (IntPtr)null)
{
TestFunction func = (TestFunction)Marshal.GetDelegateForFunctionPointer(proc,
typeof(TestFunction));
}
else
{ return; }
这样 func函数 跟dll中的TestFunction是一个功能. 通过使用func 来代替使用dll中的TestFunction.