Fosdccf.blog.chinaunix.net
sdccf
全部博文(19283)
Linux酷软(214)
tmp(0)
PostgreSQL(93)
Solaris(383)
AIX(173)
SCOUNIX(575)
DB2(1005)
Shell(386)
C/C++(1187)
MySQL(1750)
Sybase(465)
Oracle(3695)
Informix(548)
HP-UX(0)
IBM AIX(2)
Sun Solaris(0)
BSD(1)
Linux(8597)
SCO UNIX(23)
2011年(1)
2009年(125)
2008年(19094)
2007年(63)
clifford
linky521
曾德标
fengzhan
leon_yu
mcuflowe
yt200902
guanyuji
GY123456
snow888
carlos94
丸喵喵
sean229
cxunix
可怜的猪
cqxc413
xzzgege
wb123456
分类: C/C++
2008-05-18 22:47:52
#include "Unit1.h" WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { try { Application->Initialize(); Application->CreateForm(__classid(TfrmMain), &frmMain); Application->Run(); } catch (Exception &exception) { Application->ShowException(&exception); } catch (...) { try { throw Exception(""); } catch (Exception &exception) { Application->ShowException(&exception); } } if(g_bIsRunAgain) { AnsiString strPath; STARTUPINFO StartInfo; PROCESS_INFORMATION procStruct; memset(&StartInfo, 0, sizeof(STARTUPINFO)); StartInfo.cb = sizeof(STARTUPINFO); strPath = Application->ExeName; if(!::CreateProcess( (LPCTSTR) strPath.c_str(), NULL, NULL, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &StartInfo, &procStruct)) return 0; } return 0; } 主窗口的单元头文件(Unit1.h)中加入: extern bool g_bIsRunAgain; 主窗口的单元.cpp(Unit1.cpp)中加入: bool g_bIsRunAgain = false; //---------------------------------------------------------------------------- // 关闭程序 void __fastcall TfrmMain::btnCloseClick(TObject *Sender) { Close(); } //---------------------------------------------------------------------------- // 重启程序 void __fastcall TfrmMain::btnReExcuteClick(TObject *Sender) { g_bIsRunAgain = true; Close(); }
上一篇:用GDI+实现半透明渐变的特效窗口
下一篇:踏入C++中的雷区——C++内存管理详解(1)
登录 注册