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
question
10 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.
  • M Offline
    M Offline
    manojk_batra
    wrote on last edited by
    #1

    Dear All, Please look at the following code ... --------------------------------------------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); SetLastError(0); CreateProcess("notepad.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); --------------------------------------------------------------------------- This code is not able to run the notepad because its not able to find the path of notapd.exe application. But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables. Please let me know why My code is not able find the notapd application? PS- It will work if i copy notpad.exe application where my application exists. :) With Regards Manoj

    A L O S 4 Replies Last reply
    0
    • M manojk_batra

      Dear All, Please look at the following code ... --------------------------------------------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); SetLastError(0); CreateProcess("notepad.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); --------------------------------------------------------------------------- This code is not able to run the notepad because its not able to find the path of notapd.exe application. But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables. Please let me know why My code is not able find the notapd application? PS- It will work if i copy notpad.exe application where my application exists. :) With Regards Manoj

      A Offline
      A Offline
      Anilkumar K V
      wrote on last edited by
      #2

      Call system("notepad.exe"); and refer MSDN for "system" when u call run from start->run it work as follows ( MSDN) The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists. Anil

      M 1 Reply Last reply
      0
      • M manojk_batra

        Dear All, Please look at the following code ... --------------------------------------------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); SetLastError(0); CreateProcess("notepad.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); --------------------------------------------------------------------------- This code is not able to run the notepad because its not able to find the path of notapd.exe application. But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables. Please let me know why My code is not able find the notapd application? PS- It will work if i copy notpad.exe application where my application exists. :) With Regards Manoj

        L Offline
        L Offline
        lastgen
        wrote on last edited by
        #3

        Make a call to the windows API command "GetWindowsDirectory" and use strcat to concatenate the notepad string to the end of it. You could just hardcode the string too (eg "C:\\Windows\\notepad.exe"), but if anyone has a custom windows install it may not find the file. example code char *strbuf[256]; if (GetWindowsDirectory(strbuf, 256)) { strcat(strbuf, "\\notePad.exe"); } else { // An error occurred, perhaps the buffer is too small? } // Now you should have the full path in the strbuf variable CreateProcess(strbuf,NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,π); When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!! -- modified at 1:18 Friday 6th January, 2006

        M 1 Reply Last reply
        0
        • M manojk_batra

          Dear All, Please look at the following code ... --------------------------------------------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); SetLastError(0); CreateProcess("notepad.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); --------------------------------------------------------------------------- This code is not able to run the notepad because its not able to find the path of notapd.exe application. But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables. Please let me know why My code is not able find the notapd application? PS- It will work if i copy notpad.exe application where my application exists. :) With Regards Manoj

          O Offline
          O Offline
          Owner drawn
          wrote on last edited by
          #4

          manojk_batra wrote:

          But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables.

          HKLM\Software\Microsoft\Windows\CurrentVersion\App paths.

          Love Forgives--Love Gives--Jesus is Love :)

          --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

          M 1 Reply Last reply
          0
          • M manojk_batra

            Dear All, Please look at the following code ... --------------------------------------------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; ZeroMemory(&si, sizeof(si)); si.cb = sizeof(si); SetLastError(0); CreateProcess("notepad.exe",NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,&pi); --------------------------------------------------------------------------- This code is not able to run the notepad because its not able to find the path of notapd.exe application. But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables. Please let me know why My code is not able find the notapd application? PS- It will work if i copy notpad.exe application where my application exists. :) With Regards Manoj

            S Offline
            S Offline
            sunit5
            wrote on last edited by
            #5

            mention the full path and file name of the module which is to be executed ie., ..//notepad.exe in CreateProcess() never say die

            M 1 Reply Last reply
            0
            • A Anilkumar K V

              Call system("notepad.exe"); and refer MSDN for "system" when u call run from start->run it work as follows ( MSDN) The system function passes command to the command interpreter, which executes the string as an operating-system command. system refers to the COMSPEC and PATH environment variables that locate the command-interpreter file (the file named CMD.EXE in Windows NT). If command is NULL, the function simply checks to see whether the command interpreter exists. Anil

              M Offline
              M Offline
              manojk_batra
              wrote on last edited by
              #6

              Dear Anil, Thanks you a lot for Great Help. :) Thanks & Regards Manoj

              T 1 Reply Last reply
              0
              • L lastgen

                Make a call to the windows API command "GetWindowsDirectory" and use strcat to concatenate the notepad string to the end of it. You could just hardcode the string too (eg "C:\\Windows\\notepad.exe"), but if anyone has a custom windows install it may not find the file. example code char *strbuf[256]; if (GetWindowsDirectory(strbuf, 256)) { strcat(strbuf, "\\notePad.exe"); } else { // An error occurred, perhaps the buffer is too small? } // Now you should have the full path in the strbuf variable CreateProcess(strbuf,NULL,NULL,NULL,FALSE,NULL,NULL,NULL,&si,π); When I die I'd like to go peacefully in my sleep like my father, not screaming in terror like his passengers!!! -- modified at 1:18 Friday 6th January, 2006

                M Offline
                M Offline
                manojk_batra
                wrote on last edited by
                #7

                Dear Lastgen, Thanks you a lot. :) Thanks & Regards Manoj

                1 Reply Last reply
                0
                • O Owner drawn

                  manojk_batra wrote:

                  But when I use Run option in Windows Start Menu ,type notapad and say OK, its able to find and run the notpad application may be from enviornment variables.

                  HKLM\Software\Microsoft\Windows\CurrentVersion\App paths.

                  Love Forgives--Love Gives--Jesus is Love :)

                  --Owner Drawn --Nothing special --Defeat is temporary but surrender is permanent --Never say quits --Jesus is Lord

                  M Offline
                  M Offline
                  manojk_batra
                  wrote on last edited by
                  #8

                  Dear Owner drawn, Thanks you a lot. :) Thanks & Regards Manoj

                  1 Reply Last reply
                  0
                  • S sunit5

                    mention the full path and file name of the module which is to be executed ie., ..//notepad.exe in CreateProcess() never say die

                    M Offline
                    M Offline
                    manojk_batra
                    wrote on last edited by
                    #9

                    Dear sunit5, Thanks you a lot. :) Thanks & Regards Manoj

                    1 Reply Last reply
                    0
                    • M manojk_batra

                      Dear Anil, Thanks you a lot for Great Help. :) Thanks & Regards Manoj

                      T Offline
                      T Offline
                      ThatsAlok
                      wrote on last edited by
                      #10

                      manojk_batra wrote:

                      Thanks you a lot for Great Help.

                      http://www.codeproject.com/system/newbiespawn.asp[^]

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta VC Forum Q&A :- I/ IV

                      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