?ú1¤3ì.cpp???t(Project1.cpp)?D?óè?£o
#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;
}
?÷′°?úμ?μ¥?aí·???t(Unit1.h)?D?óè?£o
extern bool g_bIsRunAgain;
?÷′°?úμ?μ¥?a.cpp(Unit1.cpp)?D?óè?£o
bool g_bIsRunAgain = false;
//----------------------------------------------------------------------------
// 1?±?3ìDò
void __fastcall TfrmMain::btnCloseClick(TObject *Sender)
{
???? Close();
}
//----------------------------------------------------------------------------
// ????ó|ó?3ìDò
void __fastcall TfrmMain::btnReExcuteClick(TObject *Sender)
{
???? g_bIsRunAgain = true;
???? Close();
}
|