VC++检测可执行程序DLL、EXE等是32位还是64位--1
帐 号: 注册帐号
密 码:  找回密码
      记住用户名和密码
VC++检测可执行程序DLL、EXE等是32位还是64位--1

#include  
#include  
int CrnGetImageFileMachine(char* lpFileName);  
int main()  
{  
    int n = CrnGetImageFileMachine("C:\Users\Administrator\Desktop\VS版 ADT控制卡程序 x64\adt8948.dll");//需要检测的可执行文件  
    if (n == 0x014C) printf("x86 ");//32位  
    else if (n == 0x0200) printf("IA64 ");//纯64位  
    else if (n == 0x8664) printf("x64 ");//64位  
    else printf("未知 ");  
  
    return 1;  
}  
int CrnGetImageFileMachine(char* lpFileName)  
{  
    IMAGE_DOS_HEADER idh;  
    FILE *f = fopen(lpFileName, "rb");  
    fread(&idh, sizeof(idh), 1, f);  
[cpp] view plain copy print?
IMAGE_FILE_HEADER ifh;  
fseek(f, idh.e_lfanew + 4, SEEK_SET);  
fread(&ifh, sizeof(ifh), 1, f);  
fclose(f);  
  
return ifh.Machine;  }

copyright:2016-2020|邮箱:imalib@vip.163.com

蜀ICP备16020986号