How to avoid

Fan Young 20 信誉分
2025-04-01T03:12:35.46+00:00

I need to launch another application in current process which already called SetDllDirectory.As described here 用户的图像

child process will inherit the directory used by the calling of SetDllDirectory in parent process. My question is how avoid this? It seems that CreateProcess and ShellExecute both have this problem.By the way, I could not remove the calling of SetDllDirectory in parent process or add a calling of SetDllDirectory in child process.

Windows API - Win32
Windows API - Win32
一组适用于桌面和服务器应用程序的核心 Windows 应用程序编程接口 (API)。 以前称为 Win32 API。
136 个问题
0 个注释 无注释
{count} 票

接受的答案
  1. Junjie Zhu - MSFT 21,491 信誉分 Microsoft 外部员工
    2025-04-01T08:30:55.26+00:00

    Hello @Fan Young ,

    Welcome to Microsoft Q&A!

    According to the document,

    For Win32 processes that are not running a packaged or protected process, calling this function will also affect the DLL search order of the children processes started from the process that has called the function.

    This is by design. If you want to switch DLL directory in the win32 child process, you can only call SetDllDirectory again.

    "By the way, I could not remove the calling of SetDllDirectory in parent process or add a calling of SetDllDirectory in child process."

    It is recommended to use AddDllDirectory to add multiple DLL directories.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 个人认为此答案很有帮助。
    0 个注释 无注释

0 个其他答案

排序依据: 非常有帮助

你的答案

问题作者可以将答案标记为“接受的答案”,这有助于用户了解已解决作者问题的答案。