|
|
请使用QQ关联注册PLM之家,学习更多关于内容,更多精彩原创视频供你学习!
您需要 登录 才可以下载或查看,没有账号?注册
x
C/C++判断dll是多少位的( e5 Z+ l4 |1 j0 G" d B6 M
+ q+ `: y. n/ Y6 a u0 e: G+ P
#include <stdio.h>
& }' t$ r0 r8 d/ a! Y; g, v#include <windows.h>4 J% h# V, e2 ]8 {
% f+ N( o2 n3 J4 _3 Y5 F* _2 s6 \+ m
int __stdcall CrnGetImageFileMachine(LPCSTR lpFileName)( H4 ~7 B g4 W
/ z; x) C" d- ^" |{
1 V7 z) R, d1 ^, N) M* R2 c) ]" b( A+ v, b" p+ Z( R# K
IMAGE_DOS_HEADER idh;
. }1 c7 v7 z/ c) F: G. X2 x; ]: s% r3 R# L* z
FILE *f = fopen(lpFileName, "rb");
7 @. ?" N- K y' _0 }0 n4 m0 t1 b+ z* M: H" ^0 {5 Z6 X! B) N
fread(&idh, sizeof(idh), 1, f);" m3 m( ^& b' d: W- H. I/ |
% s/ _% J( ~( C* |1 g
9 f4 }, s- p5 W$ H IMAGE_FILE_HEADER ifh;
8 T! |7 Y; {' W* U* f) b. o& c6 b% n6 S6 `' _
fseek(f, idh.e_lfanew + 4, SEEK_SET);
" u. i% {5 y/ \+ V- V! Z( T
0 f. |" Q# S1 e- d( k fread(&ifh, sizeof(ifh), 1, f); R0 w6 O& z, C) L9 t# q
% x" M1 E) r- F
: O, ]2 a9 Q0 s) s# Y+ ^ fclose(f);5 n0 v- m- U, i f1 g
( b. ^, E2 u9 F5 Z$ o ?- G
3 \- @/ A0 u1 }8 l( }/ q4 K0 | return ifh.Machine;
, B- z+ R5 t: X2 P; ^/ ]: w0 d6 C5 Y. p0 t, U0 ^- R$ D5 w
}0 h/ r6 R7 p+ y2 A ]
T! j$ a. ?& z. h6 [+ b% Z, _
5 n" _* ~; b+ h, B$ y
- k; f' a- u8 z1 Q9 h/ O
1 s: J8 I) A% E6 k. T- C% T
// C/C++判断dll是多少位的
, U Z, M0 z- m. R& f" Z; A- E& [. ~1 R* u& Y
int n = CrnGetImageFileMachine("E:\\temp\\setup.exe");" s" l2 k4 \& T2 K0 s+ W
, _7 w' m3 S4 D3 P/ f if (n == 0x014C) ShowMessage("x86");
3 U/ L# l2 F( b2 \* K: e else if (n == 0x0200) ShowMessage("IA64");
, t4 p! t* \4 G. L9 ` else if (n == 0x8664) ShowMessage("x64");
$ g2 D: \* B* F* N6 }) A3 S else ShowMessage("抱歉检测不出来");
+ \% p2 N& W. a- m& x1 b1 @" w+ n
; u$ p6 q4 g" ~ l* u
|
|