|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
C/C++判断dll是多少位的
: R, H5 C) L" h, ?( O" I' g+ Y- C4 o
3 M: g$ d% i8 T2 W6 q) S#include <stdio.h>4 G" ~' t B( I+ D( D7 ~
#include <windows.h>
& _5 m8 A0 q# U. T- _( v, W/ y/ O2 t! e" ~7 I+ n
( s {5 C! X. F$ a. j% U) Fint __stdcall CrnGetImageFileMachine(LPCSTR lpFileName)
- A4 b9 V1 W1 g6 i! ]
4 t, ^0 d4 O F% y4 r" C: {{
, c- w+ M0 x& U* Z$ e
1 c& A) |/ [/ ]# Y& s IMAGE_DOS_HEADER idh;
4 M2 m; A- V' ]8 P4 E0 |* F4 E9 @' ~
FILE *f = fopen(lpFileName, "rb");: P0 ?2 z% A& i& W& D
0 }2 n) P8 I; y
fread(&idh, sizeof(idh), 1, f);
! h5 {( H2 u/ T/ C. X; ^) I1 q- U$ a) r3 x8 H
$ {- H! P0 F, i3 m IMAGE_FILE_HEADER ifh;- B# }& E1 a5 {9 I
' v7 e* E8 a, B9 T! t
fseek(f, idh.e_lfanew + 4, SEEK_SET);
( C T7 i- W/ a+ i4 C2 S( n7 k u% _
fread(&ifh, sizeof(ifh), 1, f);4 K z3 j$ C) i8 K$ }8 Y
4 A. G; Y+ Y2 F2 f
% \. J' B6 |3 G6 A7 h fclose(f);: k' Q" ^1 b3 }8 ~
- s! q1 d& D8 M5 k$ Y
1 b$ |* b1 H4 M6 S0 l7 p! G
return ifh.Machine;9 b( t+ U8 J$ h+ A1 ^" ]
C& f5 r5 U. m4 P& S6 f& i$ D}
6 M. J$ _2 _1 A+ u
' [. M6 c0 ~' t" { N% T9 q) |: j5 J& R6 h& `6 z6 c
+ H% I9 h$ M) \! ~. r
. c& y2 S- t% A2 y// C/C++判断dll是多少位的
N6 y# j6 |! m
" T2 s+ D9 j+ ]/ ]0 p% m: M3 b int n = CrnGetImageFileMachine("E:\\temp\\setup.exe");* u3 \( W7 A7 ^
" p8 V1 U$ [5 Q! \8 {, \9 s
if (n == 0x014C) ShowMessage("x86");8 t4 ?( L3 [: D0 `* S( R
else if (n == 0x0200) ShowMessage("IA64");
3 M0 M( a8 _- Z else if (n == 0x8664) ShowMessage("x64");
" T$ D: e$ i; d else ShowMessage("抱歉检测不出来");
5 t( l) B: w6 v; F Y* r7 [0 P5 s8 r' F
% b5 d& |% C/ a+ x6 P* @ |
|