/* 请用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 ); }

|