|
-
April 14th, 2004, 02:28 PM
#1
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
-
April 15th, 2004, 06:27 AM
#2
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.
-
April 15th, 2004, 07:50 AM
#3
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?
-
April 15th, 2004, 09:31 AM
#4
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.
-
April 15th, 2004, 09:35 AM
#5
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!
-
April 15th, 2004, 05:59 PM
#6
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.
-
April 16th, 2004, 07:54 AM
#7
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|