C#怎么调用MFC dll???

zhu6789888 2008-02-20 09:32:36
怎么引用MFC dll工程生成的dll,
在C#中 using不了 ?指点下
高手
...全文
123 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
tyb1222 2008-02-22
  • 打赏
  • 举报
回复
把.dll文件添加引用了试试..
cnwolfs 2008-02-22
  • 打赏
  • 举报
回复
api的调用方法
JasonTanJiong9 2008-02-22
  • 打赏
  • 举报
回复
关注一下
zhu6789888 2008-02-22
  • 打赏
  • 举报
回复
问题没有解决,分照给
shinaterry 2008-02-21
  • 打赏
  • 举报
回复
^o^ 4楼的, 使用完要释放...
dcba43211 2008-02-21
  • 打赏
  • 举报
回复
在程序里添加引用就可以了,不过只能引用函数,不能引用类
qshzf 2008-02-21
  • 打赏
  • 举报
回复
没有注册?
拷贝到系统目录下
拷贝到调用程序目录下
试试看
Rason401 2008-02-21
  • 打赏
  • 举报
回复
单步调试下,看看那里出问题了.
zhu6789888 2008-02-20
  • 打赏
  • 举报
回复
谢谢,好像都不能用呢 ,
Rason401 2008-02-20
  • 打赏
  • 举报
回复
[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.


liqianhong 2008-02-20
  • 打赏
  • 举报
回复
标准的`DLL就是这么调用的,没有其他方法了
USING那个只用于.NET下生成的装配件
zhu6789888 2008-02-20
  • 打赏
  • 举报
回复
谢谢,试下,还有其他方法吗 ?
lake_cx 2008-02-20
  • 打赏
  • 举报
回复
类似于这样
[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);

110,538

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧