DefaultDllImportSearchPathsAttribute DefaultDllImportSearchPathsAttribute DefaultDllImportSearchPathsAttribute DefaultDllImportSearchPathsAttribute Class

定义

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

public ref class DefaultDllImportSearchPathsAttribute sealed : Attribute
[System.AttributeUsage(System.AttributeTargets.Assembly | System.AttributeTargets.Method, AllowMultiple=false)]
[System.Runtime.InteropServices.ComVisible(false)]
public sealed class DefaultDllImportSearchPathsAttribute : Attribute
type DefaultDllImportSearchPathsAttribute = class
    inherit Attribute
Public NotInheritable Class DefaultDllImportSearchPathsAttribute
Inherits Attribute
继承
DefaultDllImportSearchPathsAttributeDefaultDllImportSearchPathsAttributeDefaultDllImportSearchPathsAttributeDefaultDllImportSearchPathsAttribute
属性

注解

应用于程序集时,此属性指定调用默认用于搜索任何平台提供了一个函数的 DLL 的路径,请在程序集中的任何代码。When applied to an assembly, this attribute specifies the paths that are used by default to search for any DLL that provides a function for a platform invoke, in any code in the assembly. 当应用于各个平台调用时,此属性将替代指定的程序集的默认搜索路径。When applied to an individual platform invoke, this attribute overrides the default search paths that were specified for the assembly.

为任何平台调用,用于指定绝对路径,则忽略此属性。This attribute is ignored for any platform invoke that specifies an absolute path.

使用此属性可防止 Win32LoadLibraryEx函数搜索当前工作目录。Use this attribute to prevent the Win32 LoadLibraryEx function from searching the current working directory. 这有助于保护你的应用程序免受攻击的恶意软件添加一个 DLL 中的当前工作目录中,以便当平台调用将调用 Win32LoadLibraryEx函数,该函数的默认搜索顺序查找恶意 DLL 改为系统 DLL 的初衷是查找。This helps protect your application from attacks in which malicious software places a DLL in the current working directory, so that when a platform invoke calls the Win32 LoadLibraryEx function, the function's default search order finds the malicious DLL instead of the system DLL it was intended to find.

公共语言运行时处理在调用LoadLibraryEx函数根据以下算法:The common language runtime handles the call to the LoadLibraryEx function according to the following algorithm:

  1. 如果该特性应用于各个平台调用,请使用指定的特性的该实例的值。If the attribute is applied to an individual platform invoke, use the values specified by that instance of the attribute.

  2. 否则为如果该特性应用于程序集包含在平台调用,请使用特性的该实例由指定的值。Otherwise, if the attribute is applied to the assembly that contains the platform invoke, use the values specified by that instance of the attribute.

  3. 否则为在程序集目录中搜索,然后调用LoadLibraryEx函数和LOAD_WITH_ALTERED_SEARCH_PATH标志。Otherwise, search the assembly directory and then call the LoadLibraryEx function with the LOAD_WITH_ALTERED_SEARCH_PATH flag.

构造函数

DefaultDllImportSearchPathsAttribute(DllImportSearchPath) DefaultDllImportSearchPathsAttribute(DllImportSearchPath) DefaultDllImportSearchPathsAttribute(DllImportSearchPath) DefaultDllImportSearchPathsAttribute(DllImportSearchPath)

初始化 DefaultDllImportSearchPathsAttribute 类的新实例,该实例指定在搜索目标平台调用时使用的路径。Initializes a new instance of the DefaultDllImportSearchPathsAttribute class, specifying the paths to use when searching for the targets of platform invokes.

属性

Paths Paths Paths Paths

获取用于指定平台调用期间 LoadLibraryEx 函数搜索路径的枚举值的按位组合。Gets a bitwise combination of enumeration values that specify the paths that the LoadLibraryEx function searches during platform invokes.

TypeId TypeId TypeId TypeId

在派生类中实现时,获取此 Attribute 的唯一标识符。When implemented in a derived class, gets a unique identifier for this Attribute.

(Inherited from Attribute)

方法

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

返回一个值,该值指示此实例是否与指定的对象相等。Returns a value that indicates whether this instance is equal to a specified object.

(Inherited from Attribute)
GetHashCode() GetHashCode() GetHashCode() GetHashCode()

返回此实例的哈希代码。Returns the hash code for this instance.

(Inherited from Attribute)
GetType() GetType() GetType() GetType()

获取当前实例的 TypeGets the Type of the current instance.

(Inherited from Object)
IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute() IsDefaultAttribute()

在派生类中重写时,指示此实例的值是否是派生类的默认值。When overridden in a derived class, indicates whether the value of this instance is the default value for the derived class.

(Inherited from Attribute)
Match(Object) Match(Object) Match(Object) Match(Object)

当在派生类中重写时,返回一个指示此实例是否等于指定对象的值。When overridden in a derived class, returns a value that indicates whether this instance equals a specified object.

(Inherited from Attribute)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

返回表示当前对象的字符串。Returns a string that represents the current object.

(Inherited from Object)

显式界面实现

_Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr) _Attribute.GetIDsOfNames(Guid, IntPtr, UInt32, UInt32, IntPtr)

将一组名称映射为对应的一组调度标识符。Maps a set of names to a corresponding set of dispatch identifiers.

(Inherited from Attribute)
_Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr) _Attribute.GetTypeInfo(UInt32, UInt32, IntPtr)

检索对象的类型信息,然后可以使用该信息获取接口的类型信息。Retrieves the type information for an object, which can be used to get the type information for an interface.

(Inherited from Attribute)
_Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32) _Attribute.GetTypeInfoCount(UInt32)

检索对象提供的类型信息接口的数量(0 或 1)。Retrieves the number of type information interfaces that an object provides (either 0 or 1).

(Inherited from Attribute)
_Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr) _Attribute.Invoke(UInt32, Guid, UInt32, Int16, IntPtr, IntPtr, IntPtr, IntPtr)

提供对某一对象公开的属性和方法的访问。Provides access to properties and methods exposed by an object.

(Inherited from Attribute)

适用于

另请参阅