CreateProcess doesn't work while ShellExecute Does!!!!
-
Hi all, I want to run ACDSee from create process this is the code i use:
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFOW);
si.wShowWindow = 1; // show
if(!CreateProcessW(L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi))
{
ASSERT(FALSE);// failure
}// success
ok , the above code seems ok, but the problem is i pass the create process sucessfully, and i can't see any ACDSEE window open (nor i can't see the process in the task manager).... if i use this substitue code:
ShellExecuteW(NULL,
L"open",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
SW_SHOWNORMAL);it is working ok and ACDSEE is opened. i can't use ShellExecute because i need some process information which PROCESS_INFORMATION structure holds.... can any1 help? thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application
-
Hi all, I want to run ACDSee from create process this is the code i use:
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFOW);
si.wShowWindow = 1; // show
if(!CreateProcessW(L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi))
{
ASSERT(FALSE);// failure
}// success
ok , the above code seems ok, but the problem is i pass the create process sucessfully, and i can't see any ACDSEE window open (nor i can't see the process in the task manager).... if i use this substitue code:
ShellExecuteW(NULL,
L"open",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
SW_SHOWNORMAL);it is working ok and ACDSEE is opened. i can't use ShellExecute because i need some process information which PROCESS_INFORMATION structure holds.... can any1 help? thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application
Not sure if this will work but the second argument of CreateProcess is the commandline parameters that will be sent to the program. So, replace it by NULL and try again.
-
Not sure if this will work but the second argument of CreateProcess is the commandline parameters that will be sent to the program. So, replace it by NULL and try again.
-
Hi all, I want to run ACDSee from create process this is the code i use:
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFOW);
si.wShowWindow = 1; // show
if(!CreateProcessW(L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi))
{
ASSERT(FALSE);// failure
}// success
ok , the above code seems ok, but the problem is i pass the create process sucessfully, and i can't see any ACDSEE window open (nor i can't see the process in the task manager).... if i use this substitue code:
ShellExecuteW(NULL,
L"open",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
SW_SHOWNORMAL);it is working ok and ACDSEE is opened. i can't use ShellExecute because i need some process information which PROCESS_INFORMATION structure holds.... can any1 help? thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application
I'm not sure if this is what the problem is as everything else looks ok, according at MSDN if your using using the
si.wShowWindow
property you need to setsi.dwFlags
toSTARTF_USESHOWWINDOW
else it'll just ignore it. Out of interest have you tried changing it to launch Word or something to check the code is working ok? Gavin Taylor w: http://www.gavspace.com -
I'm not sure if this is what the problem is as everything else looks ok, according at MSDN if your using using the
si.wShowWindow
property you need to setsi.dwFlags
toSTARTF_USESHOWWINDOW
else it'll just ignore it. Out of interest have you tried changing it to launch Word or something to check the code is working ok? Gavin Taylor w: http://www.gavspace.comalso tried it (the STARTF_USESHOWWINDOW ) and still not working... I tried creating process of notepad.exe and it works 100%!!! i think the problem is the environment while i create ACDSEE 6 process...because it works fine with ACDSEE 3....not sure why though.... any thought? thanks again Yaron Ask not what your application can do for you, Ask what you can do for your application
-
Hi all, I want to run ACDSee from create process this is the code i use:
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFOW);
si.wShowWindow = 1; // show
if(!CreateProcessW(L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi))
{
ASSERT(FALSE);// failure
}// success
ok , the above code seems ok, but the problem is i pass the create process sucessfully, and i can't see any ACDSEE window open (nor i can't see the process in the task manager).... if i use this substitue code:
ShellExecuteW(NULL,
L"open",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
SW_SHOWNORMAL);it is working ok and ACDSEE is opened. i can't use ShellExecute because i need some process information which PROCESS_INFORMATION structure holds.... can any1 help? thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application
What does
GetLastError()
tell you?
"Take only what you need and leave the land as you found it." - Native American Proverb
-
Hi all, I want to run ACDSee from create process this is the code i use:
STARTUPINFOW si;
PROCESS_INFORMATION pi;
ZeroMemory(&pi,sizeof(PROCESS_INFORMATION));
ZeroMemory(&si,sizeof(STARTUPINFO));
si.cb = sizeof(STARTUPINFOW);
si.wShowWindow = 1; // show
if(!CreateProcessW(L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
FALSE,
0,
NULL,
NULL,
&si,
&pi))
{
ASSERT(FALSE);// failure
}// success
ok , the above code seems ok, but the problem is i pass the create process sucessfully, and i can't see any ACDSEE window open (nor i can't see the process in the task manager).... if i use this substitue code:
ShellExecuteW(NULL,
L"open",
L"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe",
NULL,
NULL,
SW_SHOWNORMAL);it is working ok and ACDSEE is opened. i can't use ShellExecute because i need some process information which PROCESS_INFORMATION structure holds.... can any1 help? thanks in advanced Yaron Ask not what your application can do for you, Ask what you can do for your application
Two potential reasons: 1) the
lpCommandLine
parameter ofCreateProcessW()
is the white-space delimited list of arguments passed asargv
to the new process. If ACDSee expects to find the path to its own executable inargv[0]
the above would fail, as your path contains whitespaces. Basically the result of the above would be: argv[0]="C:\Program", argv[1]="Files\ACD", argv[2]="Systems\ACDSee\6.0}ACDSee6.exe" You should quote the string, e.g. pass it as:L"\"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe\""
2) The UNICODE-Version ofCreateProcess()
may fail on NT/2k/XP if the parameter passed aslpCommandLine
points to a constant string. This is explicitly mentioned in MSDN. Note that the type isLPWSTR
, notLPCWSTR
. Maybe you should copy your string to a modifiable buffer and pass this buffer toCreateProcessW()
: I usually pass NULL for thelpApplication
parameter and only uselpCommandLine
. Of course, you have to make sure that a path containing white-spaces is quoted in this case (as described above). ShellExecute() is intended to be more "user friendly", that is it applies some heuristics to resolve pathes containing white spaces and does other "magic stuff". Hope that helps -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D ) -
Two potential reasons: 1) the
lpCommandLine
parameter ofCreateProcessW()
is the white-space delimited list of arguments passed asargv
to the new process. If ACDSee expects to find the path to its own executable inargv[0]
the above would fail, as your path contains whitespaces. Basically the result of the above would be: argv[0]="C:\Program", argv[1]="Files\ACD", argv[2]="Systems\ACDSee\6.0}ACDSee6.exe" You should quote the string, e.g. pass it as:L"\"C:\\Program Files\\ACD Systems\\ACDSee\\6.0\\ACDSee6.exe\""
2) The UNICODE-Version ofCreateProcess()
may fail on NT/2k/XP if the parameter passed aslpCommandLine
points to a constant string. This is explicitly mentioned in MSDN. Note that the type isLPWSTR
, notLPCWSTR
. Maybe you should copy your string to a modifiable buffer and pass this buffer toCreateProcessW()
: I usually pass NULL for thelpApplication
parameter and only uselpCommandLine
. Of course, you have to make sure that a path containing white-spaces is quoted in this case (as described above). ShellExecute() is intended to be more "user friendly", that is it applies some heuristics to resolve pathes containing white spaces and does other "magic stuff". Hope that helps -- Daniel Lohmann http://www.losoft.de (Hey, this page is worth looking! You can find some free and handy NT tools there :-D )Thanks for all the replies! i've managed...the problem was that when creating acdsee6 process, you need to set up the acdsee environment (because it loads some dll that are located else where) so you can get the environment out of the registry and then use the 'SetEnvironmentVariable' method this works 100%.... to discover that, i needed to hook the ShellExecute method, and learned that it calls CreateProcess behind the scenes, with the necessary paramters that one of them was the environment looking at the memroy of that variable, i've seen the acdsee directory reference (the one that the dll reside)... so mission completed :) thanks again Yaron Ask not what your application can do for you, Ask what you can do for your application
-
What does
GetLastError()
tell you?
"Take only what you need and leave the land as you found it." - Native American Proverb