开发者

How to find working directory which works between different computers. - C

开发者 https://www.devze.com 2022-12-28 19:40 出处:网络
I am running two processes,Process A is opened by Process B using the following example: createProcessHandle = CreateProcess(

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.

  1. Use a relative path.
  2. Put the directory in your PATH environment variable. In this case, use lpCommandLine, not lpApplicationName.
0

精彩评论

暂无评论...
验证码 换一张
取 消