基本信息
源码名称:dll文件32位/64位检测工具 源码下载
源码大小:0.03M
文件格式:.rar
开发语言:C#
更新时间:2017-01-03
   友情提示:(无需注册或充值,赞助后即可获取资源下载链接)

     嘿,亲!知识可是无价之宝呢,但咱这精心整理的资料也耗费了不少心血呀。小小地破费一下,绝对物超所值哦!如有下载和支付问题,请联系我们QQ(微信同号):78630559

本次赞助数额为: 2 元 
   源码介绍

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace FileDetect
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string path = System.Environment.CurrentDirectory;
            DirectoryInfo directory = new DirectoryInfo(path);
            FileInfo[] fileInfoArray = directory.GetFiles();
            StringBuilder sb = new StringBuilder ();
            foreach (var item in fileInfoArray)
            {
                String str = String.Format("{0}:  {1}",item.Name,IsPE32(item.FullName)? "32bit":"64bit");
                sb.AppendLine(str);
            }
            textBox1.Text = sb.ToString();
        }

        public static bool IsPE32(string path)
        {
            FileStream stream = File.OpenRead(path);
            //移动到e_lfanew的位置处
            stream.Seek(0x40 - 4, SeekOrigin.Begin);
            byte[] buf = new byte[4];
            stream.Read(buf, 0, buf.Length);
            //根据e_lfanew的值计算出Machine的位置
            int pos = BitConverter.ToInt32(buf, 0)   4;
            stream.Seek(pos, SeekOrigin.Begin);
            buf = new byte[2];
            stream.Read(buf, 0, buf.Length);
            //得到Machine的值,0x14C为32位,0x8664为64位
            Int16 machine = BitConverter.ToInt16(buf, 0);
            if (machine == 0x14C)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}