15757753770 发表于 2016-12-11 15:54:03

C/C++判断dll是多少位的

C/C++判断dll是多少位的

#include <stdio.h>
#include <windows.h>


int __stdcall CrnGetImageFileMachine(LPCSTR lpFileName)

{

    IMAGE_DOS_HEADER idh;

    FILE *f = fopen(lpFileName, "rb");

    fread(&idh, sizeof(idh), 1, f);


    IMAGE_FILE_HEADER ifh;

    fseek(f, idh.e_lfanew + 4, SEEK_SET);

    fread(&ifh, sizeof(ifh), 1, f);


    fclose(f);


    return ifh.Machine;

}




// C/C++判断dll是多少位的

    int n = CrnGetImageFileMachine("E:\\temp\\setup.exe");

    if (n == 0x014C) ShowMessage("x86");
    else if (n == 0x0200) ShowMessage("IA64");
    else if (n == 0x8664) ShowMessage("x64");
    else ShowMessage("抱歉检测不出来");


页: [1]
查看完整版本: C/C++判断dll是多少位的