怎么动态调用标准windows 动态链接库?

lmpeel 2006-09-25 09:15:24
dll文件名是从数据库 动态读取的,不是.net程序集,是标准windows dll
...全文
203 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
lmpeel 2006-09-30
  • 打赏
  • 举报
回复
我在网上找到了一个解决方法,谢谢了
lmpeel 2006-09-27
  • 打赏
  • 举报
回复
就是想做到别的厂家提供dll后,我不要修改任何程序就可以接入系统,只需在数据库中增加一条记录,原来delphi下已经作好了的
lmpeel 2006-09-26
  • 打赏
  • 举报
回复
楼上几位,这种调用方法我也知道,但是这个dll文件名在程序中写死了,不能变的,也就不是动态了。
比如系统中需要访问很多厂家的设备时,我需要从数据库中找到厂家对应的dll然后去调用即可,以前在delphi中很容易做到的,现在c#不知怎么写了
Apq001 2006-09-26
  • 打赏
  • 举报
回复
动态调用,我也想,关注下。
周公 2006-09-26
  • 打赏
  • 举报
回复
[DllImport("gdi32.dll", EntryPoint="AbortDoc")]
public static extern int AbortDoc (
int hdc
);

[DllImport("gdi32.dll", EntryPoint="AbortPath")]
public static extern int AbortPath (
int hdc
);

[DllImport("winmm.dll", EntryPoint="PlaySound")]
public static extern int PlaySound (
string lpszName,
int hModule,
int dwFlags
);
yzqlee 2006-09-26
  • 打赏
  • 举报
回复
[DllImport("kernel32")]
private static extern long WritePrivateProfileString(string section,
string key, string val, string filePath);

public void IniWriteValue(string Section, string Key, string Value)
{
WritePrivateProfileString(Section, Key, Value, this.path);
}
lmpeel 2006-09-26
  • 打赏
  • 举报
回复
再顶
注册失败 2006-09-26
  • 打赏
  • 举报
回复
.NET中的Assembly是可以动态调用的,个人想法:对不同的厂家的dll创建不同的Assembly,这样就能在程序中使用动态加载Assembly的方法加载你需要的dll了
jiezhi 2006-09-25
  • 打赏
  • 举报
回复
那你可以使用动态生成.net assembly的方法,assembly中再调dll。
你去查查Emit方法。一些aop的lib中就使用了这样的技术。
lmpeel 2006-09-25
  • 打赏
  • 举报
回复
怎么没人啊
lmpeel 2006-09-25
  • 打赏
  • 举报
回复
[DllImport ("ddd.dll")]
属性必须是常数表达式 ??
lmpeel 2006-09-25
  • 打赏
  • 举报
回复
谢谢jiezhi(风满袖) ,

有没有写过的朋友贴段代码出来啊!!!!

110,571

社区成员

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

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

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