I am running two processes,Process A is opened by Process B using the following example:
createProcessHandle = CreateProcess(
TEXT("C:\\Users\Jamie\\Documents\\Application\\Debug\\ProcessA.exe"),
TEXT(""),
NULL,
NULL,
FALSE,
0,
开发者_StackOverflow NULL,
NULL,
&startupinfo,
&process_information
);
As you can see the Process is reliant on the path given to it, the problem I have is that if I change the location of my ProcessA.exe (Such as a backup/duplicate) it's a tiresome process to keep recoding the path. I want to be able to make it run no matter where it is without having to recode the path manually.
Can anybody suggest a solution to this?
Edit: I do not have access to the path environment variable
There are basically two options.
- Use a relative path.
- Put the directory in your PATH environment variable. In this case, use lpCommandLine, not lpApplicationName.
精彩评论