CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7
  1. #1
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175

    Create Process / Child Processes

    If you use CreateProcess to start a process, can it spawn child processes or do you have to give it special permissions? I understand that any child process spawned by default will have the same security rights as the parent process. The problem is that I use CreateProcess to start the application but when it tries to open the chile process it doesn't show up. If I start the process normally (by double-clicking) it works fine.

    This is how I create the process:

    CreateProcess( NULL, // No module name (use command line).
    "C:\\Program Files\\Internet Explorer\\iexplore.exe http://tandis106:10500/idxwf/Default.htm", // Command line.
    NULL, // Process handle not inheritable.
    NULL, // Thread handle not inheritable.
    FALSE, // Set handle inheritance to FALSE.
    NORMAL_PRIORITY_CLASS, // No creation flags.
    NULL, // Use parent's environment block.
    NULL, // Use parent's starting directory.
    &si, // Pointer to STARTUPINFO structure.
    &pi )

    Am I missing something?

    Thanks,
    Dale

  2. #2
    Join Date
    Nov 2000
    Location
    Munich, Germany
    Posts
    161
    Your commandline requires quoted strings!
    Currently, CreateProcess tries to start C:\Program.exe because that's where the first blank separates program and parameters.
    The rest of your commandline is passed as parameters.
    The Saviour of the World is a Penguin and Linus Torvalds is his Prophet.

  3. #3
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175
    Strange, but it is quoted from what I am looking at.

    "C:\\Program Files\\Internet Explorer\\iexplore.exe http://tandis106:10500/idxwf/Default.htm",

    Are you seeing something different?

  4. #4
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    How do you initialize PROCESS_INFORMATION and STARTUPINFO structures?

    I have just built a 2 sample apps one launching another using CreateProcess and second app launching explorer. Everything works fine.

    By the way: child process runs under the same security context as parent process.
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  5. #5
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175
    HANDLE StartInternetExplorerLCJ()
    {
    STARTUPINFO si;
    PROCESS_INFORMATION pi;
    HANDLE WFLCJProcess;

    ZeroMemory( &si, sizeof(si) );
    si.cb = sizeof(si);
    ZeroMemory( &pi, sizeof(pi) );

    if(CreateProcess( NULL, "C:\\Program Files\\Internet Explorer\\iexplore.exe http://tandis106:10500/idxwf/Default.htm", &sa, NULL, FALSE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &pi)
    )
    {
    Sleep(2000);
    WFLCJProcess = &pi.hProcess;
    WFLCJProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, pi.dwProcessId);
    }
    else
    {
    MessageBox(NULL, "CreateProcess failed.", "Error!", NULL);
    }
    return WFLCJProcess;
    }

    Thanks for your help!

  6. #6
    Join Date
    May 1999
    Location
    ALABAMA, USA
    Posts
    9,917
    I really do not see any problem with this code.
    Did you try GetLastError?

    What is this for?
    Originally posted by drm15
    Sleep(2000);
    WFLCJProcess = &pi.hProcess;
    WFLCJProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE,
    There are only 10 types of people in the world:
    Those who understand binary and those who do not.

  7. #7
    Join Date
    Oct 2003
    Location
    Minnesota
    Posts
    175
    I think I figured it out late last night. I had all of my logic before the windows message pump. I have changed my code so that I am passing messages back and forth now instead of trying to do everything before the pump. It seems to be working now.

    Thanks to everyone for your help!

    Dale

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured