如何找到在不同计算机之间工作的工作目录。 -C

发布于 2024-08-30 22:18:00 字数 623 浏览 3 评论 0原文

我正在运行两个进程,进程 A 由进程 B 使用以下示例打开:

    createProcessHandle = CreateProcess(
TEXT("C:\\Users\Jamie\\Documents\\Application\\Debug\\ProcessA.exe"),
                    TEXT(""),
                    NULL,
                    NULL,
                    FALSE,
                    0,
                    NULL,
                    NULL,
                    &startupinfo,
                    &process_information
                    );

如您所见,进程依赖于给定的路径,我遇到的问题是,如果我更改 ProcessA.exe 的位置(例如备份/重复),不断重新编码路径是一个令人厌烦的过程。我希望能够让它运行,无论它在哪里,而不必手动重新编码路径。

有人可以建议解决这个问题吗?

编辑:我无权访问路径环境变量

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,
                    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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

离鸿 2024-09-06 22:18:00

基本上有两种选择。

  1. 使用相对路径。
  2. 将目录放入 PATH 环境变量中。在这种情况下,使用 lpCommandLine,而不是 lpApplicationName。

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.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文