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. createprocess

createprocess

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorial
9 Posts 6 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.
  • D Offline
    D Offline
    dellthinker
    wrote on last edited by
    #1

    Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

    L M H D M 5 Replies Last reply
    0
    • D dellthinker

      Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      So the "example" provided in the MSDN online documentation is not "simple" enough? or you can't get it to work? or....???

      1 Reply Last reply
      0
      • D dellthinker

        Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

        M Offline
        M Offline
        Mark Salsbery
        wrote on last edited by
        #3

        You can pass NULL, 0, and/or FALSE for all the parameters except lpApplicationName, lpStartupInfo, and lpProcessInformation. That should simplify it :) Mark

        Mark Salsbery Microsoft MVP - Visual C++ :java:

        1 Reply Last reply
        0
        • D dellthinker

          Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

          H Offline
          H Offline
          Hamed Musavi
          wrote on last edited by
          #4

          You might want to take a look at this: http://www.codeproject.com/threads/CreateProcessEx.asp [^]

          // "Life is very short and is very fragile also." Yanni
          while (I'm_alive)
          {
          cout<<"I love programming.";
          }

          1 Reply Last reply
          0
          • D dellthinker

            Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

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

            dellthinker wrote:

            I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly.

            :omg: Beyond words. Why not show us what you've tried so we can see where you've gone astray?


            "A good athlete is the result of a good and worthy opponent." - David Crow

            "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

            D 1 Reply Last reply
            0
            • D David Crow

              dellthinker wrote:

              I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly.

              :omg: Beyond words. Why not show us what you've tried so we can see where you've gone astray?


              "A good athlete is the result of a good and worthy opponent." - David Crow

              "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

              D Offline
              D Offline
              dellthinker
              wrote on last edited by
              #6

              Im having trouble with this. #include #include using namespace std; int main(i) { CreateProcess(("notpad.exe"),NULL,NULL,NULL,FALSE,0,NULL,NULL,NULL,NULL); printf("Failed because: %s", GetLastError()); return 0; }

              D M 2 Replies Last reply
              0
              • D dellthinker

                Im having trouble with this. #include #include using namespace std; int main(i) { CreateProcess(("notpad.exe"),NULL,NULL,NULL,FALSE,0,NULL,NULL,NULL,NULL); printf("Failed because: %s", GetLastError()); return 0; }

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

                dellthinker wrote:

                int main(i)

                What's this?

                dellthinker wrote:

                printf("Failed because: %s", GetLastError());

                Should be:

                printf("Failed because: %lu", GetLastError());


                "A good athlete is the result of a good and worthy opponent." - David Crow

                "To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne

                1 Reply Last reply
                0
                • D dellthinker

                  Hi all, I've been struggling with the WinAPI CreateProcess for some time now. I've googled/yahoo'ed all over to find a simple explanation on how to use it and i havnt found anything close to how to use it properly. I know it takes 10 parameters in order to use so says MSDN. But im still not finding a way to use it for something simply. Any help and or suggestions on the matter is greatly appreciated. Thanx in advance!

                  M Offline
                  M Offline
                  Michael Dunn
                  wrote on last edited by
                  #8

                  See the FAQ 6.4 How do I run another program from my program?[^]

                  --Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Hungarian notation FTW

                  1 Reply Last reply
                  0
                  • D dellthinker

                    Im having trouble with this. #include #include using namespace std; int main(i) { CreateProcess(("notpad.exe"),NULL,NULL,NULL,FALSE,0,NULL,NULL,NULL,NULL); printf("Failed because: %s", GetLastError()); return 0; }

                    M Offline
                    M Offline
                    Mark Salsbery
                    wrote on last edited by
                    #9

                    Is "notpad.exe" the app you want to run? Also you need to pass something to those last two parameters, especially the last one, since there's some handles returned that need to be freed.

                    STARTUPINFO StartupInfo;
                        memset(&StartupInfo, 0, sizeof(STARTUPINFO));
                        StartupInfo.cb = sizeof(STARTUPINFO);

                    PROCESS_INFORMATION ProcessInformation;

                    if (0 == ::CreateProcess(_T("C:\\Windows\\system32\\notepad.exe"), //  LPCTSTR lpApplicationName,
                                                NULL,                    //  LPTSTR lpCommandLine,
                                                NULL,                    //  LPSECURITY_ATTRIBUTES lpProcessAttributes,
                                                NULL,                    //  LPSECURITY_ATTRIBUTES lpThreadAttributes,
                                                FALSE,                   //  BOOL bInheritHandles,
                                                NORMAL_PRIORITY_CLASS,   //  DWORD dwCreationFlags,
                                                NULL,                    //  LPVOID lpEnvironment,
                                                NULL,                    //  LPCTSTR lpCurrentDirectory,
                                                &StartupInfo,     &n

                    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