Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to restart MFC application from within itself

How to restart MFC application from within itself

Scheduled Pinned Locked Moved C / C++ / MFC
c++helptutorialquestion
14 Posts 8 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Offline
    V Offline
    Vinod Moorkkan
    wrote on last edited by
    #1

    Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

    J P H 2 P 6 Replies Last reply
    0
    • V Vinod Moorkkan

      Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

      P Offline
      P Offline
      prasad_som
      wrote on last edited by
      #2

      Can you be more clear ?

      Prasad Notifier using ATL | Operator new[],delete[][^]

      1 Reply Last reply
      0
      • V Vinod Moorkkan

        Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

        J Offline
        J Offline
        jhwurmbach
        wrote on last edited by
        #3

        Vinod Moorkkan wrote:

        Now i wanted to restart my MFC application from within itself.

        To start an EXE in another process, you can use system( "filename"). Its prototype should be included with any MFC-Program or you can include for it. Your old aplication then simply terminates.


        "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

        T 1 Reply Last reply
        0
        • V Vinod Moorkkan

          Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

          H Offline
          H Offline
          Hamid Taebi
          wrote on last edited by
          #4

          Can you more explain restart my MFC application from within itself?


          WhiteSky


          1 Reply Last reply
          0
          • V Vinod Moorkkan

            Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

            2 Offline
            2 Offline
            224917
            wrote on last edited by
            #5

            There is no in build function to do that i believe. One approach could be starting a new instance of the current application and then exit the current instance (some more inteligence can be given to the application through the command line parameters like to wait till the parent application has cleaned-up the resource and exited properly before initializing the new instance).

            T 1 Reply Last reply
            0
            • V Vinod Moorkkan

              Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

              P Offline
              P Offline
              Peter Wucherer
              wrote on last edited by
              #6

              Use Create Process. I have tested it with a dialog based app. Maybe you must use some startup time delay to wait until the calling application is closed. For more information about CreateProcess have alook in the MSDN. void CRestart_selfDlg::OnButtonRestart() { STARTUPINFO m_StartupInfo; PROCESS_INFORMATION m_ProcessInformation; ZeroMemory(&m_StartupInfo, sizeof(STARTUPINFO)); ZeroMemory(&m_ProcessInformation, sizeof(PROCESS_INFORMATION)); char* szPrgPathName = "\"restart_self.exe\""; CreateProcess ( NULL , szPrgPathName // the commandline options , (LPSECURITY_ATTRIBUTES)NULL , (LPSECURITY_ATTRIBUTES)NULL , FALSE , CREATE_NEW_CONSOLE , NULL , NULL , &m_StartupInfo , &m_ProcessInformation) ; DWORD dwLastError = GetLastError(); // for test only // close now the dialog based application OnOK(); // should work in view based application, not tested // theApp.CloseAllDocuments(TRUE); }

              1 Reply Last reply
              0
              • J jhwurmbach

                Vinod Moorkkan wrote:

                Now i wanted to restart my MFC application from within itself.

                To start an EXE in another process, you can use system( "filename"). Its prototype should be included with any MFC-Program or you can include for it. Your old aplication then simply terminates.


                "We trained hard, but it seemed that every time we were beginning to form up into teams we would be reorganised. I was to learn later in life that we tend to meet any new situation by reorganising: and a wonderful method it can be for creating the illusion of progress, while producing confusion, inefficiency and demoralisation." -- Caius Petronius, Roman Consul, 66 A.D.

                T Offline
                T Offline
                toxcct
                wrote on last edited by
                #7

                prefer ::ShellExecute() or ::CreateProcess() than system()


                Don't know where to start ?
                Refer the Forums Guidelines and ask a friend

                [VisualCalc 3.0][Flags Beginner's Guide]

                H 1 Reply Last reply
                0
                • 2 224917

                  There is no in build function to do that i believe. One approach could be starting a new instance of the current application and then exit the current instance (some more inteligence can be given to the application through the command line parameters like to wait till the parent application has cleaned-up the resource and exited properly before initializing the new instance).

                  T Offline
                  T Offline
                  toxcct
                  wrote on last edited by
                  #8

                  you here !? welcome back, and happy new year :rose::cool: ps: arrange your sig and close the opened html tag ;)


                  Don't know where to start ?
                  Refer the Forums Guidelines and ask a friend

                  [VisualCalc 3.0][Flags Beginner's Guide]

                  2 1 Reply Last reply
                  0
                  • T toxcct

                    you here !? welcome back, and happy new year :rose::cool: ps: arrange your sig and close the opened html tag ;)


                    Don't know where to start ?
                    Refer the Forums Guidelines and ask a friend

                    [VisualCalc 3.0][Flags Beginner's Guide]

                    2 Offline
                    2 Offline
                    224917
                    wrote on last edited by
                    #9

                    toxcct wrote:

                    welcome back, and happy new year

                    Thanks a tonn toxcct. glad to see you still remember ! Wish you the same and all the best for 2007 :rose: Thought of doing something good for this 07 and ended up back here in CP :cool:

                    toxcct wrote:

                    ps: arrange your sig and close the opened html tag

                    still in search for a new sig for the new year ;)

                    T 1 Reply Last reply
                    0
                    • T toxcct

                      prefer ::ShellExecute() or ::CreateProcess() than system()


                      Don't know where to start ?
                      Refer the Forums Guidelines and ask a friend

                      [VisualCalc 3.0][Flags Beginner's Guide]

                      H Offline
                      H Offline
                      Hamid Taebi
                      wrote on last edited by
                      #10

                      Congratulation new icon its nice :-D


                      WhiteSky


                      T 1 Reply Last reply
                      0
                      • 2 224917

                        toxcct wrote:

                        welcome back, and happy new year

                        Thanks a tonn toxcct. glad to see you still remember ! Wish you the same and all the best for 2007 :rose: Thought of doing something good for this 07 and ended up back here in CP :cool:

                        toxcct wrote:

                        ps: arrange your sig and close the opened html tag

                        still in search for a new sig for the new year ;)

                        T Offline
                        T Offline
                        toxcct
                        wrote on last edited by
                        #11

                        of course i remember you, you were one of the 1st who left me a message in my "CP Blog"... btw, i wish you to fine your new sig... lol


                        Don't know where to start ?
                        Refer the Forums Guidelines and ask a friend

                        [VisualCalc 3.0][Flags Beginner's Guide]

                        1 Reply Last reply
                        0
                        • H Hamid Taebi

                          Congratulation new icon its nice :-D


                          WhiteSky


                          T Offline
                          T Offline
                          toxcct
                          wrote on last edited by
                          #12

                          WhiteSky wrote:

                          Congratulation new icon its nice

                          thanks :cool::rose:


                          Don't know where to start ?
                          Refer the Forums Guidelines and ask a friend

                          [VisualCalc 3.0][Flags Beginner's Guide]

                          1 Reply Last reply
                          0
                          • V Vinod Moorkkan

                            Hello friends... I am working with vc++6.Now i wanted to restart my MFC application from within itself.How can i make it possible. Please help me Thanks

                            S Offline
                            S Offline
                            Sumesh V V
                            wrote on last edited by
                            #13

                            Use can use CreateProcess() to start ur MFC application and then exit ur current exe. :)

                            V 1 Reply Last reply
                            0
                            • S Sumesh V V

                              Use can use CreateProcess() to start ur MFC application and then exit ur current exe. :)

                              V Offline
                              V Offline
                              Vinod Moorkkan
                              wrote on last edited by
                              #14

                              Thank you..friends.. I used CreateProcess it working..

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups