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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. CreateProcess return code 1 however Process does not start

CreateProcess return code 1 however Process does not start

Scheduled Pinned Locked Moved C / C++ / MFC
11 Posts 4 Posters 3 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.
  • F Offline
    F Offline
    ForNow
    wrote on last edited by
    #1

    Hi, I am getting back a 1 from CreateProcess indicting success however the process never takes off I can cann't find it in TaskManager Either Here is the code this code used to work I just cleaned up my computer tried re-building the app

    strncpy(&herc_command[0],"HERC_CMD.EXE ",13);

         memset(&si,0,sizeof(si));
         si.cb= sizeof(si);
    
    
    
           sa.nLength =  sizeof(sa);
           sa.lpSecurityDescriptor = NULL;
           sa.bInheritHandle = TRUE;     // Hercmd will inherit this event
    
           hutil\_module = GetModuleHandle("HENGINE");
    
    
          hercgui\_addr = GetProcAddress(hutil\_module,"hercgui\_proc");
    
          if (hercgui\_addr == NULL)
               errcd = GetLastError();
    
          strncpy(&herc\_parm\[0\],&hercgui\_addr,8);
    
    
    
       return\_code = CreateProcess((LPCSTR) &herc\_command\[0\],      // command
                                   (LPCSTR) &herc\_parm\[0\],         // paramter
                                   (LPCSTR) &sa,
                                   NULL,
                                   TRUE,
                                   (DWORD) NULL,
                                   NULL,
                                   NULL,
                                   &si,
                                   &pi);
    
    if (return\_code == 0 )
        errcd = GetLastError();
    
    S D 2 Replies Last reply
    0
    • F ForNow

      Hi, I am getting back a 1 from CreateProcess indicting success however the process never takes off I can cann't find it in TaskManager Either Here is the code this code used to work I just cleaned up my computer tried re-building the app

      strncpy(&herc_command[0],"HERC_CMD.EXE ",13);

           memset(&si,0,sizeof(si));
           si.cb= sizeof(si);
      
      
      
             sa.nLength =  sizeof(sa);
             sa.lpSecurityDescriptor = NULL;
             sa.bInheritHandle = TRUE;     // Hercmd will inherit this event
      
             hutil\_module = GetModuleHandle("HENGINE");
      
      
            hercgui\_addr = GetProcAddress(hutil\_module,"hercgui\_proc");
      
            if (hercgui\_addr == NULL)
                 errcd = GetLastError();
      
            strncpy(&herc\_parm\[0\],&hercgui\_addr,8);
      
      
      
         return\_code = CreateProcess((LPCSTR) &herc\_command\[0\],      // command
                                     (LPCSTR) &herc\_parm\[0\],         // paramter
                                     (LPCSTR) &sa,
                                     NULL,
                                     TRUE,
                                     (DWORD) NULL,
                                     NULL,
                                     NULL,
                                     &si,
                                     &pi);
      
      if (return\_code == 0 )
          errcd = GetLastError();
      
      S Offline
      S Offline
      Santhosh G_
      wrote on last edited by
      #2

      Please ensure the target is not started, by adding some log in that process. If process terminates as soon as the startup, then TaskManager cant show it. Please check the values of returned PROCESS_INFORMATION structure. Process ID is avaialable in pi.dwProcessId.

      return_code = CreateProcess((LPCSTR) &herc_command[0], // command
      (LPCSTR) &herc_parm[0], // paramter
      (LPCSTR) &sa,
      NULL,
      TRUE,
      (DWORD) NULL,
      NULL,
      NULL,
      &si,
      &pi);

      Is third parameter is correct? Conversion to a string is not correct.

      F 1 Reply Last reply
      0
      • S Santhosh G_

        Please ensure the target is not started, by adding some log in that process. If process terminates as soon as the startup, then TaskManager cant show it. Please check the values of returned PROCESS_INFORMATION structure. Process ID is avaialable in pi.dwProcessId.

        return_code = CreateProcess((LPCSTR) &herc_command[0], // command
        (LPCSTR) &herc_parm[0], // paramter
        (LPCSTR) &sa,
        NULL,
        TRUE,
        (DWORD) NULL,
        NULL,
        NULL,
        &si,
        &pi);

        Is third parameter is correct? Conversion to a string is not correct.

        F Offline
        F Offline
        ForNow
        wrote on last edited by
        #3

        I run the code under the debugger in VS 2010 In the child process I have a __debugbreak at the beginning of the code Ill move it up to CWinApp::InitInstance as that would seem close to the first piece of code being executed Thanks

        1 Reply Last reply
        0
        • F ForNow

          Hi, I am getting back a 1 from CreateProcess indicting success however the process never takes off I can cann't find it in TaskManager Either Here is the code this code used to work I just cleaned up my computer tried re-building the app

          strncpy(&herc_command[0],"HERC_CMD.EXE ",13);

               memset(&si,0,sizeof(si));
               si.cb= sizeof(si);
          
          
          
                 sa.nLength =  sizeof(sa);
                 sa.lpSecurityDescriptor = NULL;
                 sa.bInheritHandle = TRUE;     // Hercmd will inherit this event
          
                 hutil\_module = GetModuleHandle("HENGINE");
          
          
                hercgui\_addr = GetProcAddress(hutil\_module,"hercgui\_proc");
          
                if (hercgui\_addr == NULL)
                     errcd = GetLastError();
          
                strncpy(&herc\_parm\[0\],&hercgui\_addr,8);
          
          
          
             return\_code = CreateProcess((LPCSTR) &herc\_command\[0\],      // command
                                         (LPCSTR) &herc\_parm\[0\],         // paramter
                                         (LPCSTR) &sa,
                                         NULL,
                                         TRUE,
                                         (DWORD) NULL,
                                         NULL,
                                         NULL,
                                         &si,
                                         &pi);
          
          if (return\_code == 0 )
              errcd = GetLastError();
          
          D Offline
          D Offline
          David Crow
          wrote on last edited by
          #4

          Since CreateProcess() returns before the process has been fully initialized (e.g., waiting on some other DLL to load), it would have no way of knowing that. It goes ahead and returns a non-zero value because it did start the process.

          "One man's wage rise is another man's price increase." - Harold Wilson

          "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

          "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

          F 1 Reply Last reply
          0
          • D David Crow

            Since CreateProcess() returns before the process has been fully initialized (e.g., waiting on some other DLL to load), it would have no way of knowing that. It goes ahead and returns a non-zero value because it did start the process.

            "One man's wage rise is another man's price increase." - Harold Wilson

            "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

            "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

            F Offline
            F Offline
            ForNow
            wrote on last edited by
            #5

            Since CWinApp::CWinApp is the first piece of executable code as far as I am concerned I would set a breakpoint e.g. (__debugbreak) at that location if it doesn't get there where else would I look ? Thanks

            F 1 Reply Last reply
            0
            • F ForNow

              Since CWinApp::CWinApp is the first piece of executable code as far as I am concerned I would set a breakpoint e.g. (__debugbreak) at that location if it doesn't get there where else would I look ? Thanks

              F Offline
              F Offline
              Freak30
              wrote on last edited by
              #6

              I dont't think the target process will be started under the debugger by the host process. There are three possible things I can think of testing. First, in the project settings of the target app enter the same parameters you would recieve from the host process. Then start debugging and see if the app starts or if it aborts as well. Second, try starting another process, e.g. cmd.exe, from the host process to check if this works at all. Third, use as little parameters as possible and possibly log (or check in debugger) the values before passing them to the CreateProcess() call to see if they really are what you expect them to be.

              F 1 Reply Last reply
              0
              • F Freak30

                I dont't think the target process will be started under the debugger by the host process. There are three possible things I can think of testing. First, in the project settings of the target app enter the same parameters you would recieve from the host process. Then start debugging and see if the app starts or if it aborts as well. Second, try starting another process, e.g. cmd.exe, from the host process to check if this works at all. Third, use as little parameters as possible and possibly log (or check in debugger) the values before passing them to the CreateProcess() call to see if they really are what you expect them to be.

                F Offline
                F Offline
                ForNow
                wrote on last edited by
                #7

                I tried entering the .exe on cmd.exe and it just returned, next I tried starting it from Task Manager and it and I saw it pop up for a second , tried to debug it and got invalid handle as it disappeared My guess I have a CWinApp to start things off and some how I didn't build it as a MFC project On my property pages -> Project Default USE of MFC -> USe MFC as Shared DLL maybe its something else in my project settings Any Ideas are welcome

                D 1 Reply Last reply
                0
                • F ForNow

                  I tried entering the .exe on cmd.exe and it just returned, next I tried starting it from Task Manager and it and I saw it pop up for a second , tried to debug it and got invalid handle as it disappeared My guess I have a CWinApp to start things off and some how I didn't build it as a MFC project On my property pages -> Project Default USE of MFC -> USe MFC as Shared DLL maybe its something else in my project settings Any Ideas are welcome

                  D Offline
                  D Offline
                  David Crow
                  wrote on last edited by
                  #8

                  ForNow wrote:

                  I tried entering the .exe on cmd.exe and it just returned...

                  Is it a dialog-based app, or some other app that has a doc/view?

                  "One man's wage rise is another man's price increase." - Harold Wilson

                  "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                  "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                  F 1 Reply Last reply
                  0
                  • D David Crow

                    ForNow wrote:

                    I tried entering the .exe on cmd.exe and it just returned...

                    Is it a dialog-based app, or some other app that has a doc/view?

                    "One man's wage rise is another man's price increase." - Harold Wilson

                    "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                    "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                    F Offline
                    F Offline
                    ForNow
                    wrote on last edited by
                    #9

                    It has a MainWindow CFrameWnd Something about the way I build it I think

                    D 1 Reply Last reply
                    0
                    • F ForNow

                      It has a MainWindow CFrameWnd Something about the way I build it I think

                      D Offline
                      D Offline
                      David Crow
                      wrote on last edited by
                      #10

                      ForNow wrote:

                      It has a MainWindow CFrameWnd

                      SDI or MDI?

                      ForNow wrote:

                      Something about the way I build it I think

                      That's kind of what I was leaning towards. If it was a dialog-based app, I was going to suggest to you to use the DS_NOFAILCREATE style.

                      "One man's wage rise is another man's price increase." - Harold Wilson

                      "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                      "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                      F 1 Reply Last reply
                      0
                      • D David Crow

                        ForNow wrote:

                        It has a MainWindow CFrameWnd

                        SDI or MDI?

                        ForNow wrote:

                        Something about the way I build it I think

                        That's kind of what I was leaning towards. If it was a dialog-based app, I was going to suggest to you to use the DS_NOFAILCREATE style.

                        "One man's wage rise is another man's price increase." - Harold Wilson

                        "Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons

                        "Show me a community that obeys the Ten Commandments and I'll show you a less crowded prison system." - Anonymous

                        F Offline
                        F Offline
                        ForNow
                        wrote on last edited by
                        #11

                        I think SDI as there is only 1 MainWindow and dialogs Modal and non-modal that come in response to user selection

                        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