不算原创,算是实践吧
网上搜了些资料,照做效果不是很好,
就把几种做法综合尝试一下,算达到了自己比较满意的效果
1. release版,(废话),程序还有24k
2. Project Setting ->Linker勾上 Ignore all default libraries,加上所需的库(msvcrt.lib,等),减到16k
3. 加了#pragramm comment(linker, "/opt:nowin98"),减到5k
4. 再加上区段合并,减到4k
没试再加壳,自己基本满意了
附一个头文件,直接引用,编译出的程序减到3k,强人真多啊
#ifdef NDEBUG #pragma optimize("gsy",on) #pragma comment(linker,"RELEASE") #ifdef _MERGE_RDATA_ #pragma comment(linker,"/merge:.rdata=.data") #endif #pragma comment(linker,"/merge:.text=.data") #pragma comment(linker,"/merge:.reloc=.data") #if _MSC_VER >= 1000 #endif #endif #pragma comment(linker,"/ENTRY:WinMain") #pragma comment(linker,"/merge:.rdata=.data") #pragma comment(linker,"/merge:.text=.data") #pragma comment(lib,"msvcrt.lib") #if (_MSC_VER < 1300) #pragma comment(linker,"/IGNORE:4078") #pragma comment(linker,"/OPT:NOWIN98") #endif #define WIN32_LEAN_AND_MEAN