c#怎么判断一个dll是x86的还是x64平台的

举报 回答
c#怎么判断一个dll是x86的还是x64平台的
问在线客服
扫码问在线客服
  • 回答数

    7

  • 浏览数

    2,312

举报 回答

7个回答 默认排序
  • 默认排序
  • 按时间排序

没找到满意答案?去问秘塔AI搜索
取消 复制问题
已采纳
我们可以通过dll的PE Image File中指定位置的字节来判断dll文件是x86的还是x64的。如下是代码示例:
public static ushort GetPEArchitecture(string pFilePath)
{
ushort architecture = 0;
try
{
using (System.IO.FileStream fStream = new System.IO.FileStream(pFilePath, System.IO.FileMode.Open, System.IO.FileAccess.Read))
{
using (System.IO.BinaryReader bReader = new System.IO.BinaryReader(fStream))
{
if (bReader.ReadUInt16() == 23117) //check the MZ signature
{
fStream.Seek(0x3A, System.IO.SeekOrigin.Current); //seek to e_lfanew.
fStream.Seek(bReader.ReadUInt32(), System.IO.SeekOrigin.Begin); //seek to the start of the NT header.
if (bReader.ReadUInt32() == 17744) //check the PE\0\0 signature.
{
fStream.Seek(20, System.IO.SeekOrigin.Current); //seek past the file header,
architecture = bReader.ReadUInt16(); //read the magic number of the optional header.
}
}
}
}
}
catch (Exception) { /* TODO: Any exception handling you want to do, personally I just take 0 as a sign of failure */}
//if architecture returns 0, there has been an error.
return architecture;
}

执行上面的代码会返回下面两种可能的结果:
0x10b - PE32
0x20b - PE32+

前者是x86的后者是x64的
------------------
这么简单的问题百度一下就知道了嘛~
取消 评论
你可以找另一台的电脑上去复制下这个缺失的文件,看看能否解决问题
或者你可以尝试使用腾讯电脑管家来修复缺失DLL文件
具体方法是,打开腾讯电脑管家--电脑诊所--软件问题--丢失.Dll 文件--一键修复--完成
如果还是解决不了,去脚本之家下一个文件直接复制进去就能搞定了
如果找不到,还可以下载一个dx修复工具3.0增强版,去修复一下
取消 评论
们可以通过dll的PE Image File中指定位置的字节来判断dll文件是x86的还是x64的。如下是代码示例:
public static ushort GetPEArchitecture(string filePath){ ushort architecture = 0; try { using (System.IO.FileStream fStream = new System.IO.FileStream(filePath, System.IO.FileMode.Open, System.IO.FileAccess.Read)) { using (System.IO.BinaryReader bReader = new System.IO.BinaryReader(fStream)) { if (bReader.ReadUInt16() == 23117) { fStream.Seek(0x3A, System.IO.SeekOrigin.Current); fStream.Seek(bReader.ReadUInt32(), System.IO.SeekOrigin.Begin); if (bReader.ReadUInt32() == 17744) { fStream.Seek(20, System.IO.SeekOrigin.Current); architecture = bReader.ReadUInt16(); \ } } } } } catch { } return architecture;}
执行上面的代码会返回下面两种可能的结果:
0x10b - PE320x20b - PE32+前者是x86的后者是x64的。
取消 评论
查看电脑是X64系统还是x86系统的操作如下(以Win10为例说明):1、在开始菜单的windows图标点击右键,弹出右键菜单,如下图:2、在上图红框处,点击“系统”项,弹出系统窗口,如下图:在上图“系统”窗口的红框处,(示例)显示系统类型为“64位操作系统,基于64位的处理器”,即X64。如果是32位操作系统,则为X86。如此,可判断电脑是X64系统还是x86系统。
取消 评论
留着吧,没有删的必要,要是你删了 ,然后你机器上某某软件运行不理来,你又不知怎么弄。。。
取消 评论
可以看下源程序和源代码 有相应的标示的
取消 评论
ZOL问答 > c#怎么判断一个dll是x86的还是x64平台的

相关产品

  • 爱国者X86

    爱国者X86

    参考价:¥699    评分:8.4

    热门排行榜:未上榜

  • 京东搜一搜

举报

感谢您为社区的和谐贡献力量请选择举报类型

举报成功

经过核实后将会做出处理
感谢您为社区和谐做出贡献

扫码参与新品0元试用
晒单、顶楼豪礼等你拿

扫一扫,关注我们
提示

确定要取消此次报名,退出该活动?