如何用VC写出1k多的程序呢?付源码!

王朝vc·作者佚名  2006-01-09
宽屏版  字体: |||超大  

/*

请用VC编译,就可生成一个1.5Kb的程序了!是不是很小呢?

2005.4.10 By Ken

*/

#include <tchar.h>

#include <windows.h>

#pragma comment(linker, "/OPT:NOWIN98")

#pragma comment(linker, "/ENTRY:KenMain") //设置程序入口

#pragma comment(linker, "/merge:.data=.text") //合并段

#pragma comment(linker, "/merge:.rdata=.text")

class CKen{

public:

CKen(){

m_pName=_T("Ken");

m_pJob=NULL;

}

virtual ~CKen(){

TCHAR TextBuf[512];

if(m_pJob)

wsprintf(TextBuf,_T("%s 在 %s 开始上班了,但由于不认真工作,又失业了!"),GetName(),GetJob());

else

wsprintf(TextBuf,_T("%s 至今还未找到工作!"),GetName());

MessageBox(NULL,TextBuf,NULL,NULL);

m_pName=NULL;

m_pJob=NULL;

}

LPCTSTR GetName(){return m_pName;}

LPCTSTR GetJob(){return m_pJob;}

void SetJob(LPCTSTR pNewJob){m_pJob=pNewJob;}

CKen *Run();

protected:

LPTSTR m_pName;

LPCTSTR m_pJob;

};

static LPCTSTR Employment_Agency[]={_T("某某电脑公司"),_T("深圳某某网络公司"),

_T("上海某某软件公司"),_T("某某网络清洁公司")};

CKen *CKen::Run(){

SYSTEMTIME SystemTime;

TCHAR TextBuf[512];

GetLocalTime(&SystemTime);

wsprintf(TextBuf,_T("今天是%d年%d月%d日,以下是%s的求职近况!"),

SystemTime.wYear,SystemTime.wMonth,SystemTime.wDay,GetName());

MessageBox(NULL,TextBuf,NULL,NULL);

for(int Num=0;Num<sizeof(Employment_Agency)/sizeof(LPCTSTR);Num++){

wsprintf(TextBuf,_T("%s 是否想录用 %s"),Employment_Agency[Num],GetName());

if(MessageBox(NULL,TextBuf,NULL,MB_YESNO)==IDYES){

SetJob(Employment_Agency[Num]);

break;

}

}

return this;

}

/*int APIENTRY WinMain(HINSTANCE hInstance,HINSTANCE hPrevInstance,

LPSTR lpCmdLine,int nCmdShow){

delete ((new CKen())->Run());

return 0;

}*/

void KenMain(){

delete ((new CKen())->Run());

ExitProcess(0);

}

void * __cdecl operator new( unsigned int cb ){

return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, cb );

}

void __cdecl operator delete( void * p ){

if(p)HeapFree( GetProcessHeap(), 0, p );

}

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
© 2005- 王朝网络 版权所有