导入基于64位或32位操作系统外部DLL [英] Import external dll based on 64bit or 32bit OS

查看:288
本文介绍了导入基于64位或32位操作系统外部DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我进来的32位和64位版本的DLL。我的.NET WinForm的配置为任何CPU和我的老板不会让我们有不同的操作系统版本单独安装。所以我想知道:如果我包两个DLL文件在安装,那么有没有办法让在WinForm判断其64位/ 32位和加载正确的DLL

I have a dll that comes in both 32bit and 64bit version. My .NET WinForm is configured for "Any CPU" and my boss will not let us have separate installs for the different OS versions. So I am wondering: if I package both dlls in the install, then is there a way to have the WinForm determine if its 64bit/32bit and load the proper dll.

我发现这篇文章确定的版本。但我不知道如何注入适当的 方式来定义上我想使用的方法DllImport属性。任何想法?

I found this article for determining version. But i am not sure how to inject the proper way to define the DLLImport attribute on the methods i wish to use. Any ideas?

推荐答案

可以导入他们俩,并就通过.NET调用哪一个的决定呢?

Can you import them both and make the decision about which one to call via .NET instead?

例如:

[DllImport("32bit.dll", CharSet = CharSet.Unicode, EntryPoint="CallMe")]
public static extern int CallMe32 (IntPtr hWnd, String text, String caption, uint type);

[DllImport("64bit.dll", CharSet = CharSet.Unicode, EntryPoint="CallMe")]
public static extern int CallMe64 (IntPtr hWnd, String text, String caption, uint type);

这篇关于导入基于64位或32位操作系统外部DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆