国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

在程序中重啟自己的一種方法

2019-11-17 05:10:16
字體:
來源:轉載
供稿:網友

  在工程.cpp文件(PRoject1.cpp)中加入:

  #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();
  }

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 新晃| 鄱阳县| 祁门县| 治县。| 华亭县| 正蓝旗| 普洱| 汉中市| 黄石市| 文昌市| 天长市| 石河子市| 始兴县| 辽宁省| 东兴市| 托里县| 土默特左旗| 济阳县| 商南县| 武山县| 汉沽区| 民丰县| 湟中县| 西乡县| 泉州市| 普陀区| 千阳县| 广元市| 海丰县| 互助| 许昌市| 正蓝旗| 济南市| 揭东县| 黎平县| 新河县| 文水县| 大兴区| 托克逊县| 浦县| 重庆市|