DllImportSearchPath Enum


指定用于搜索提供平台调用函数的 DLL 的路径。Specifies the paths that are used to search for DLLs that provide functions for platform invokes.

This enumeration has a FlagsAttribute attribute that allows a bitwise combination of its member values.

public enum class DllImportSearchPath
public enum DllImportSearchPath
type DllImportSearchPath = 
Public Enum DllImportSearchPath


ApplicationDirectory 512

在 DLL 的搜索路径中包含了应用程序目录。Include the application directory in the DLL search path.

AssemblyDirectory 2

当搜索程序集依赖项时,请包括包含程序集本身的目录并首先查找该目录。When searching for assembly dependencies, include the directory that contains the assembly itself, and search that directory first. 在路径传递到 Win32 LoadLibraryEx 函数之前,通过 .NET Framework 使用此值。This value is used by the .NET Framework, before the paths are passed to the Win32 LoadLibraryEx function.

LegacyBehavior 0

搜索应用程序目录,然后调用有 LOAD_WITH_ALTERED_SEARCH_PATH 标志的 Win32 LoadLibraryEx 函数。Search the application directory, and then call the Win32 LoadLibraryEx function with the LOAD_WITH_ALTERED_SEARCH_PATH flag. 如果指定任何其他值,则忽略该值。This value is ignored if any other value is specified. 不支持 DefaultDllImportSearchPathsAttribute 特性使用此值并忽略其他值的操作系统。Operating systems that do not support the DefaultDllImportSearchPathsAttribute attribute use this value, and ignore other values.

SafeDirectories 4096

在 DLL 搜索路径中包含了应用程序目录、%WinDir%\System32 目录和用户目录。Include the application directory, the %WinDir%\System32 directory, and user directories in the DLL search path.

System32 2048

在 DLL 搜索路径中包含了 %WinDir%\System32 目录。Include the %WinDir%\System32 directory in the DLL search path.

UseDllDirectoryForDependencies 256

搜索在搜索其他文件夹之前 DLL 所在文件夹中的依赖项。Search for the dependencies of a DLL in the folder where the DLL is located before searching other folders.

UserDirectories 1024

通过使用 Win32 AddDllDirectory 函数,包含了显式添加了过程搜索路径的所有路径。Include any path that was explicitly added to the process-wide search path by using the Win32 AddDllDirectory function.


使用 DefaultDllImportSearchPathsAttribute 特性可以将一组路径应用于整个程序集或单个平台调用。Use the DefaultDllImportSearchPathsAttribute attribute to apply a set of paths to an entire assembly or to an individual platform invoke.

Applies to