The System.Runtime.InteropServices namespace provides a wide variety of members that support COM interop and platform invoke services. If you are unfamiliar with these services, see Interoperating with Unmanaged Code.

类:


说明
System_CAPS_pubclassAllowReversePInvokeCallsAttribute

Allows an unmanaged method to call a managed method.

System_CAPS_pubclassAutomationProxyAttribute

Specifies whether the type should be marshaled using the Automation marshaler or a custom proxy and stub.

System_CAPS_pubclassBestFitMappingAttribute

Controls whether Unicode characters are converted to the closest matching ANSI characters.

System_CAPS_pubclassBStrWrapper

Marshals data of type VT_BSTR from managed to unmanaged code. This class cannot be inherited.

System_CAPS_pubclassClassInterfaceAttribute

Indicates the type of class interface to be generated for a class exposed to COM, if an interface is generated at all.

System_CAPS_pubclassCoClassAttribute

Specifies the class identifier of a coclass imported from a type library.

System_CAPS_pubclassComAliasNameAttribute

Indicates the COM alias for a parameter or field type.

System_CAPS_pubclassComAwareEventInfo

Permits late-bound registration of an event handler.

System_CAPS_pubclassComCompatibleVersionAttribute

Indicates to a COM client that all classes in the current version of an assembly are compatible with classes in an earlier version of the assembly.

System_CAPS_pubclassComConversionLossAttribute

Indicates that information was lost about a class or interface when it was imported from a type library to an assembly.

System_CAPS_pubclassComDefaultInterfaceAttribute

Specifies a default interface to expose to COM. This class cannot be inherited.

System_CAPS_pubclassComEventInterfaceAttribute

Identifies the source interface and the class that implements the methods of the event interface that is generated when a coclass is imported from a COM type library.

System_CAPS_pubclassComEventsHelper

Provides methods that enable .NET Framework delegates that handle events to be added and removed from COM objects.

System_CAPS_pubclassCOMException

The exception that is thrown when an unrecognized HRESULT is returned from a COM method call.

System_CAPS_pubclassComImportAttribute

Indicates that the attributed type was previously defined in COM.

System_CAPS_pubclassComRegisterFunctionAttribute

Specifies the method to call when you register an assembly for use from COM; this enables the execution of user-written code during the registration process.

System_CAPS_pubclassComSourceInterfacesAttribute

Identifies a list of interfaces that are exposed as COM event sources for the attributed class.

System_CAPS_pubclassComUnregisterFunctionAttribute

Specifies the method to call when you unregister an assembly for use from COM; this allows for the execution of user-written code during the unregistration process.

System_CAPS_pubclassComVisibleAttribute

Controls accessibility of an individual managed type or member, or of all types within an assembly, to COM.

System_CAPS_pubclassCriticalHandle

Represents a wrapper class for handle resources.

System_CAPS_pubclassCurrencyWrapper

Wraps objects the marshaler should marshal as a VT_CY.

System_CAPS_pubclassDefaultCharSetAttribute

Specifies the value of the CharSet enumeration. This class cannot be inherited.

System_CAPS_pubclassDefaultDllImportSearchPathsAttribute

Specifies the paths that are used to search for DLLs that provide functions for platform invokes.

System_CAPS_pubclassDefaultParameterValueAttribute

Sets the default value of a parameter when called from a language that supports default parameters. This class cannot be inherited.

System_CAPS_pubclassDispatchWrapper

Wraps objects the marshaler should marshal as a VT_DISPATCH.

System_CAPS_pubclassDispIdAttribute

Specifies the COM dispatch identifier (DISPID) of a method, field, or property.

System_CAPS_pubclassDllImportAttribute

Indicates that the attributed method is exposed by an unmanaged dynamic-link library (DLL) as a static entry point.

System_CAPS_pubclassErrorWrapper

Wraps objects the marshaler should marshal as a VT_ERROR.

System_CAPS_pubclassExtensibleClassFactory

Enables customization of managed objects that extend from unmanaged objects during creation.

System_CAPS_pubclassExternalException

The base exception type for all COM interop exceptions and structured exception handling (SEH) exceptions.

System_CAPS_pubclassFieldOffsetAttribute

Indicates the physical position of fields within the unmanaged representation of a class or structure.

System_CAPS_pubclassGuidAttribute

Supplies an explicit System.Guid when an automatic GUID is undesirable.

System_CAPS_pubclassHandleCollector

Tracks outstanding handles and forces a garbage collection when the specified threshold is reached.

System_CAPS_pubclassIDispatchImplAttribute

已过时。Indicates which IDispatch implementation the common language runtime uses when exposing dual interfaces and dispinterfaces to COM.

System_CAPS_pubclassImportedFromTypeLibAttribute

Indicates that the types defined within an assembly were originally defined in a type library.

System_CAPS_pubclassInAttribute

Indicates that data should be marshaled from the caller to the callee, but not back to the caller.

System_CAPS_pubclassInterfaceTypeAttribute

Indicates whether a managed interface is dual, dispatch-only, or IUnknown -only when exposed to COM.

System_CAPS_pubclassInvalidComObjectException

The exception thrown when an invalid COM object is used.

System_CAPS_pubclassInvalidOleVariantTypeException

The exception thrown by the marshaler when it encounters an argument of a variant type that can not be marshaled to managed code.

System_CAPS_pubclassLCIDConversionAttribute

Indicates that a method's unmanaged signature expects a locale identifier (LCID) parameter.

System_CAPS_pubclassManagedToNativeComInteropStubAttribute

Provides support for user customization of interop stubs in managed-to-COM interop scenarios.

System_CAPS_pubclassMarshal

Provides a collection of methods for allocating unmanaged memory, copying unmanaged memory blocks, and converting managed to unmanaged types, as well as other miscellaneous methods used when interacting with unmanaged code.

System_CAPS_pubclassMarshalAsAttribute

Indicates how to marshal the data between managed and unmanaged code.

System_CAPS_pubclassMarshalDirectiveException

The exception that is thrown by the marshaler when it encounters a MarshalAsAttribute it does not support.

System_CAPS_pubclassOptionalAttribute

Indicates that a parameter is optional.

System_CAPS_pubclassOutAttribute

Indicates that data should be marshaled from callee back to caller.

System_CAPS_pubclassPreserveSigAttribute

Indicates that the HRESULT or retval signature transformation that takes place during COM interop calls should be suppressed.

System_CAPS_pubclassPrimaryInteropAssemblyAttribute

Indicates that the attributed assembly is a primary interop assembly.

System_CAPS_pubclassProgIdAttribute

Allows the user to specify the ProgID of a class.

System_CAPS_pubclassRegistrationServices

Provides a set of services for registering and unregistering managed assemblies for use from COM.

System_CAPS_pubclassRuntimeEnvironment

Provides a collection of static methods that return information about the common language runtime environment.

System_CAPS_pubclassSafeArrayRankMismatchException

The exception thrown when the rank of an incoming SAFEARRAY does not match the rank specified in the managed signature.

System_CAPS_pubclassSafeArrayTypeMismatchException

The exception thrown when the type of the incoming SAFEARRAY does not match the type specified in the managed signature.

System_CAPS_pubclassSafeBuffer

Provides a controlled memory buffer that can be used for reading and writing. Attempts to access memory outside the controlled buffer (underruns and overruns) raise exceptions.

System_CAPS_pubclassSafeHandle

Represents a wrapper class for operating system handles. This class must be inherited.

System_CAPS_pubclassSEHException

Represents structured exception handling (SEH) errors.

System_CAPS_pubclassSetWin32ContextInIDispatchAttribute

已过时。This attribute has been deprecated.

System_CAPS_pubclassStandardOleMarshalObject

Replaces the standard common language runtime (CLR) free-threaded marshaler with the standard OLE STA marshaler.

System_CAPS_pubclassStructLayoutAttribute

Lets you control the physical layout of the data fields of a class or structure in memory.

System_CAPS_pubclassTypeIdentifierAttribute

Provides support for type equivalence.

System_CAPS_pubclassTypeLibConverter

Provides a set of services that convert a managed assembly to a COM type library and vice versa.

System_CAPS_pubclassTypeLibFuncAttribute

Contains the FUNCFLAGS that were originally imported for this method from the COM type library.

System_CAPS_pubclassTypeLibImportClassAttribute

Specifies which Type exclusively uses an interface. This class cannot be inherited.

System_CAPS_pubclassTypeLibTypeAttribute

Contains the TYPEFLAGS that were originally imported for this type from the COM type library.

System_CAPS_pubclassTypeLibVarAttribute

Contains the VARFLAGS that were originally imported for this field from the COM type library.

System_CAPS_pubclassTypeLibVersionAttribute

Specifies the version number of an exported type library.

System_CAPS_pubclassUnknownWrapper

Wraps objects the marshaler should marshal as a VT_UNKNOWN.

System_CAPS_pubclassUnmanagedFunctionPointerAttribute

Controls the marshaling behavior of a delegate signature passed as an unmanaged function pointer to or from unmanaged code. This class cannot be inherited.

System_CAPS_pubclassVariantWrapper

Marshals data of type VT_VARIANT | VT_BYREF from managed to unmanaged code. This class cannot be inherited.

结构:


结构说明
System_CAPS_pubstructureArrayWithOffset

Encapsulates an array and an offset within the specified array.

System_CAPS_pubstructureBIND_OPTS

已过时。Use System.Runtime.InteropServices.ComTypes.BIND_OPTS instead.

System_CAPS_pubstructureBINDPTR

已过时。Use System.Runtime.InteropServices.ComTypes.BINDPTR instead.

System_CAPS_pubstructureCONNECTDATA

已过时。Use System.Runtime.InteropServices.ComTypes.CONNECTDATA instead.

System_CAPS_pubstructureELEMDESC.DESCUNION

Use System.Runtime.InteropServices.ComTypes.ELEMDESC.DESCUNION instead.

System_CAPS_pubstructureVARDESC.DESCUNION

Use System.Runtime.InteropServices.ComTypes.VARDESC.DESCUNION instead.

System_CAPS_pubstructureDISPPARAMS

已过时。Use System.Runtime.InteropServices.ComTypes.DISPPARAMS instead.

System_CAPS_pubstructureELEMDESC

已过时。Use System.Runtime.InteropServices.ComTypes.ELEMDESC instead.

System_CAPS_pubstructureEXCEPINFO

已过时。Use System.Runtime.InteropServices.ComTypes.EXCEPINFO instead.

System_CAPS_pubstructureFILETIME

已过时。Use System.Runtime.InteropServices.ComTypes.FILETIME instead.

System_CAPS_pubstructureFUNCDESC

已过时。Use System.Runtime.InteropServices.ComTypes.FUNCDESC instead.

System_CAPS_pubstructureGCHandle

Provides a way to access a managed object from unmanaged memory.

System_CAPS_pubstructureHandleRef

Wraps a managed object holding a handle to a resource that is passed to unmanaged code using platform invoke.

System_CAPS_pubstructureIDLDESC

已过时。Use System.Runtime.InteropServices.ComTypes.IDLDESC instead.

System_CAPS_pubstructurePARAMDESC

已过时。Use System.Runtime.InteropServices.ComTypes.PARAMDESC instead.

System_CAPS_pubstructureSTATSTG

已过时。Use System.Runtime.InteropServices.ComTypes.STATSTG instead.

System_CAPS_pubstructureTYPEATTR

已过时。Use System.Runtime.InteropServices.ComTypes.TYPEATTR instead.

System_CAPS_pubstructureTYPEDESC

已过时。Use System.Runtime.InteropServices.ComTypes.TYPEDESC instead.

System_CAPS_pubstructureTYPELIBATTR

已过时。Use System.Runtime.InteropServices.ComTypes.TYPELIBATTR instead.

System_CAPS_pubstructureVARDESC

已过时。Use System.Runtime.InteropServices.ComTypes.VARDESC instead.

接口:


接口说明
System_CAPS_pubinterface_Activator

Exposes the System.Activator class to unmanaged code.

System_CAPS_pubinterface_Assembly

Exposes the public members of the System.Reflection.Assembly class to unmanaged code.

System_CAPS_pubinterface_AssemblyBuilder

Exposes the System.Reflection.Emit.AssemblyBuilder class to unmanaged code.

System_CAPS_pubinterface_AssemblyName

Exposes the AssemblyName class to unmanaged code.

System_CAPS_pubinterface_Attribute

Exposes the System.Attribute class to unmanaged code.

System_CAPS_pubinterface_ConstructorBuilder

Exposes the System.Reflection.Emit.ConstructorBuilder class to unmanaged code.

System_CAPS_pubinterface_ConstructorInfo

Exposes the public members of the System.Reflection.ConstructorInfo class to unmanaged code.

System_CAPS_pubinterface_CustomAttributeBuilder

Exposes the System.Reflection.Emit.CustomAttributeBuilder class to unmanaged code.

System_CAPS_pubinterface_EnumBuilder

Exposes the System.Reflection.Emit.EnumBuilder class to unmanaged code.

System_CAPS_pubinterface_EventBuilder

Exposes the System.Reflection.Emit.EventBuilder class to unmanaged code.

System_CAPS_pubinterface_EventInfo

Exposes the public members of the System.Reflection.EventInfo class to unmanaged code.

System_CAPS_pubinterface_Exception

Exposes the public members of the System.Exception class to unmanaged code.

System_CAPS_pubinterface_FieldBuilder

Exposes the System.Reflection.Emit.FieldBuilder class to unmanaged code.

System_CAPS_pubinterface_FieldInfo

Exposes the public members of the System.Reflection.FieldInfo class to unmanaged code.

System_CAPS_pubinterface_ILGenerator

Exposes the System.Reflection.Emit.ILGenerator class to unmanaged code.

System_CAPS_pubinterface_LocalBuilder

Exposes the System.Reflection.Emit.LocalBuilder class to unmanaged code.

System_CAPS_pubinterface_MemberInfo

Exposes the public members of the System.Reflection.MemberInfo class to unmanaged code.

System_CAPS_pubinterface_MethodBase

Exposes the public members of the System.Reflection.MethodBase class to unmanaged code.

System_CAPS_pubinterface_MethodBuilder

Exposes the MethodBuilder class to unmanaged code.

System_CAPS_pubinterface_MethodInfo

Exposes the public members of the System.Reflection.MethodInfo class to unmanaged code.

System_CAPS_pubinterface_MethodRental

Exposes the System.Reflection.Emit.MethodRental class to unmanaged code.

System_CAPS_pubinterface_Module

Exposes the Module class to unmanaged code.

System_CAPS_pubinterface_ModuleBuilder

Exposes the System.Reflection.Emit.ModuleBuilder class to unmanaged code.

System_CAPS_pubinterface_ParameterBuilder

Exposes the System.Reflection.Emit.ParameterBuilder class to unmanaged code.

System_CAPS_pubinterface_ParameterInfo

Exposes the System.Reflection.ParameterInfo class to unmanaged code.

System_CAPS_pubinterface_PropertyBuilder

Exposes the System.Reflection.Emit.PropertyBuilder class to unmanaged code.

System_CAPS_pubinterface_PropertyInfo

Exposes the public members of the System.Reflection.PropertyInfo class to unmanaged code.

System_CAPS_pubinterface_SignatureHelper

Exposes the System.Reflection.Emit.SignatureHelper class to unmanaged code.

System_CAPS_pubinterface_Thread

Exposes the System.Threading.Thread class to unmanaged code.

System_CAPS_pubinterface_Type

Exposes the public members of the System.Type class to the unmanaged code.

System_CAPS_pubinterface_TypeBuilder

Exposes the System.Reflection.Emit.TypeBuilder class to unmanaged code.

System_CAPS_pubinterfaceICustomAdapter

Provides a way for clients to access the actual object, rather than the adapter object handed out by a custom marshaler.

System_CAPS_pubinterfaceICustomFactory

Enables users to write activation code for managed objects that extend MarshalByRefObject.

System_CAPS_pubinterfaceICustomMarshaler

Provides custom wrappers for handling method calls.

System_CAPS_pubinterfaceICustomQueryInterface

Enables developers to provide a custom, managed implementation of the IUnknown::QueryInterface(REFIID riid, void **ppvObject) method.

System_CAPS_pubinterfaceIRegistrationServices

Provides a set of services for registering and unregistering managed assemblies for use from COM.

System_CAPS_pubinterfaceITypeLibConverter

Provides a set of services that convert a managed assembly to a COM type library and vice versa.

System_CAPS_pubinterfaceITypeLibExporterNameProvider

Provides control over the casing of names when exported to a type library.

System_CAPS_pubinterfaceITypeLibExporterNotifySink

Provides a callback mechanism for the assembly converter to inform the caller of the status of the conversion, and involve the caller in the conversion process itself.

System_CAPS_pubinterfaceITypeLibImporterNotifySink

Provides a callback mechanism for the type library converter to inform the caller of the status of the conversion, and involve the caller in the conversion process itself.

System_CAPS_pubinterfaceUCOMIBindCtx

已过时。Use System.Runtime.InteropServices.ComTypes.BIND_OPTS instead.

System_CAPS_pubinterfaceUCOMIConnectionPoint

已过时。Use System.Runtime.InteropServices.ComTypes.IConnectionPoint instead.

System_CAPS_pubinterfaceUCOMIConnectionPointContainer

已过时。Use System.Runtime.InteropServices.ComTypes.IConnectionPointContainer instead.

System_CAPS_pubinterfaceUCOMIEnumConnectionPoints

已过时。Use System.Runtime.InteropServices.ComTypes.IEnumConnectionPoints instead.

System_CAPS_pubinterfaceUCOMIEnumConnections

已过时。Use System.Runtime.InteropServices.ComTypes.IEnumConnections instead.

System_CAPS_pubinterfaceUCOMIEnumMoniker

已过时。Use System.Runtime.InteropServices.ComTypes.IEnumMoniker instead.

System_CAPS_pubinterfaceUCOMIEnumString

已过时。Use System.Runtime.InteropServices.ComTypes.IEnumString instead.

System_CAPS_pubinterfaceUCOMIEnumVARIANT

已过时。Use System.Runtime.InteropServices.ComTypes.IEnumVARIANT instead.

System_CAPS_pubinterfaceUCOMIMoniker

已过时。Use System.Runtime.InteropServices.ComTypes.IMoniker instead.

System_CAPS_pubinterfaceUCOMIPersistFile

已过时。Use System.Runtime.InteropServices.ComTypes.IPersistFile instead.

System_CAPS_pubinterfaceUCOMIRunningObjectTable

已过时。Use System.Runtime.InteropServices.ComTypes.IRunningObjectTable instead.

System_CAPS_pubinterfaceUCOMIStream

已过时。Use System.Runtime.InteropServices.ComTypes.IStream instead.

System_CAPS_pubinterfaceUCOMITypeComp

已过时。Use System.Runtime.InteropServices.ComTypes.ITypeComp instead.

System_CAPS_pubinterfaceUCOMITypeInfo

已过时。Use System.Runtime.InteropServices.ComTypes.ITypeInfo instead.

System_CAPS_pubinterfaceUCOMITypeLib

已过时。Use System.Runtime.InteropServices.ComTypes.ITypeLib instead.

委托:


委托说明
System_CAPS_pubdelegateObjectCreationDelegate

Creates a COM object.

枚举:


枚举说明
System_CAPS_pubenumAssemblyRegistrationFlags

Defines a set of flags used when registering assemblies.

System_CAPS_pubenumCALLCONV

已过时。Use System.Runtime.InteropServices.ComTypes.CALLCONV instead.

System_CAPS_pubenumCallingConvention

Specifies the calling convention required to call methods implemented in unmanaged code.

System_CAPS_pubenumCharSet

Dictates which character set marshaled strings should use.

System_CAPS_pubenumClassInterfaceType

Identifies the type of class interface that is generated for a class.

System_CAPS_pubenumComInterfaceType

Identifies how to expose an interface to COM.

System_CAPS_pubenumComMemberType

Describes the type of a COM member.

System_CAPS_pubenumCustomQueryInterfaceMode

Indicates whether the GetComInterfaceForObject(Object,Type,CustomQueryInterfaceMode) method's IUnknown::QueryInterface calls can use the ICustomQueryInterface interface.

System_CAPS_pubenumCustomQueryInterfaceResult

Provides return values for the GetInterface method.

System_CAPS_pubenumDESCKIND

已过时。Use System.Runtime.InteropServices.ComTypes.DESCKIND instead.

System_CAPS_pubenumDllImportSearchPath

Specifies the paths that are used to search for DLLs that provide functions for platform invokes.

System_CAPS_pubenumExporterEventKind

Describes the callbacks that the type library exporter makes when exporting a type library.

System_CAPS_pubenumFUNCFLAGS

已过时。Use System.Runtime.InteropServices.ComTypes.FUNCFLAGS instead.

System_CAPS_pubenumFUNCKIND

已过时。Use System.Runtime.InteropServices.ComTypes.FUNCKIND instead.

System_CAPS_pubenumGCHandleType

Represents the types of handles the GCHandle class can allocate.

System_CAPS_pubenumIDispatchImplType

已过时。Indicates which IDispatch implementation to use for a particular class.

System_CAPS_pubenumIDLFLAG

已过时。Use System.Runtime.InteropServices.ComTypes.IDLFLAG instead.

System_CAPS_pubenumIMPLTYPEFLAGS

已过时。Use System.Runtime.InteropServices.ComTypes.IMPLTYPEFLAGS instead.

System_CAPS_pubenumImporterEventKind

Describes the callbacks that the type library importer makes when importing a type library.

System_CAPS_pubenumINVOKEKIND

已过时。Use System.Runtime.InteropServices.ComTypes.INVOKEKIND instead.

System_CAPS_pubenumLayoutKind

Controls the layout of an object when exported to unmanaged code.

System_CAPS_pubenumLIBFLAGS

已过时。Use System.Runtime.InteropServices.ComTypes.LIBFLAGS instead.

System_CAPS_pubenumPARAMFLAG

已过时。Use System.Runtime.InteropServices.ComTypes.PARAMFLAG instead.

System_CAPS_pubenumRegistrationClassContext

Specifies the set of execution contexts in which a class object will be made available for requests to construct instances.

System_CAPS_pubenumRegistrationConnectionType

Defines the types of connections to a class object.

System_CAPS_pubenumSYSKIND

已过时。Use System.Runtime.InteropServices.ComTypes.SYSKIND instead.

System_CAPS_pubenumTYPEFLAGS

已过时。Use System.Runtime.InteropServices.ComTypes.TYPEFLAGS instead.

System_CAPS_pubenumTYPEKIND

已过时。Use System.Runtime.InteropServices.ComTypes.TYPEKIND instead.

System_CAPS_pubenumTypeLibExporterFlags

Indicates how a type library should be produced.

System_CAPS_pubenumTypeLibFuncFlags

Describes the original settings of the FUNCFLAGS in the COM type library from where this method was imported.

System_CAPS_pubenumTypeLibImporterFlags

Indicates how an assembly should be produced.

System_CAPS_pubenumTypeLibTypeFlags

Describes the original settings of the TYPEFLAGS in the COM type library from which the type was imported.

System_CAPS_pubenumTypeLibVarFlags

Describes the original settings of the VARFLAGS in the COM type library from which the variable was imported.

System_CAPS_pubenumUnmanagedType

Identifies how to marshal parameters or fields to unmanaged code.

System_CAPS_pubenumVarEnum

Indicates how to marshal the array elements when an array is marshaled from managed to unmanaged code as a UnmanagedType.SafeArray.

System_CAPS_pubenumVARFLAGS

已过时。Use System.Runtime.InteropServices.ComTypes.VARFLAGS instead.

备注:

Members of this namespace provide several categories of functionality, as shown in the following table. Attributes control marshaling behavior, such as how to arrange structures or how to represent strings. The most important attributes are DllImportAttribute, which you use to define platform invoke methods for accessing unmanaged APIs, and MarshalAsAttribute, which you use to specify how data is marshaled between managed and unmanaged memory.




转载自:https://msdn.microsoft.com/zh-cn/library/9esea608(v=vs.110).aspx#%E6%9E%9A%E4%B8%BE