다음을 통해 공유


InAttribute 클래스

데이터가 호출자에서 피호출자로 마샬링되어야 하고, 호출자에게는 다시 마샬링되지 않아도 됨을 나타냅니다.

네임스페이스: System.Runtime.InteropServices
어셈블리: mscorlib(mscorlib.dll)

구문

‘선언
<AttributeUsageAttribute(AttributeTargets.Parameter, Inherited:=False)> _
<ComVisibleAttribute(True)> _
Public NotInheritable Class InAttribute
    Inherits Attribute
‘사용 방법
Dim instance As InAttribute
[AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false)] 
[ComVisibleAttribute(true)] 
public sealed class InAttribute : Attribute
[AttributeUsageAttribute(AttributeTargets::Parameter, Inherited=false)] 
[ComVisibleAttribute(true)] 
public ref class InAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false) */ 
/** @attribute ComVisibleAttribute(true) */ 
public final class InAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Parameter, Inherited=false) 
ComVisibleAttribute(true) 
public final class InAttribute extends Attribute

설명

이 특성을 매개 변수에 적용할 수 있습니다.

InAttribute는 선택 사항입니다. 이 특성은 COM interop과 플랫폼 호출에만 지원됩니다. 명시적 설정이 없으면 interop 마샬러는 매개 변수의 형식, 매개 변수가 참조로 전달되는지 또는 값으로 전달되는지 여부 및 형식이 blittable인지 blittable이 아닌지 여부를 기준으로 규칙을 사용합니다. 예를 들어, StringBuilder 클래스는 항상 In/Out으로 취급되고, 값으로 전달되는 문자열 배열은 In으로 취급됩니다.

C# 스타일 out 키워드를 사용하여 수정한 매개 변수에는 InAttribute를 적용할 수 없습니다. Visual Basic의 In 키워드를 InAttribute, 마이너스 특성과 혼동하지 않으려면 특성을 대괄호로 묶어 <[In]> 형식으로 사용합니다.

InAttributeOutAttribute를 조합하면 배열과 서식이 지정된 blittable 이외의 형식에 적용되는 경우 특히 유용합니다. 이 두 속성을 모두 적용한 경우에만 피호출자가 이러한 형식에 변경한 내용을 호출자가 볼 수 있습니다. 이러한 형식은 마샬링 하는 동안 복사를 요구하기 때문에, InAttributeOutAttribute를 사용하여 불필요한 복사본을 줄일 수 있습니다.

마샬링 동작에서 InAttribute의 효과에 대한 자세한 내용은 방향 특성을 참조하십시오.

예제

다음 예제에서는 매개 변수로 배열을 전달하는 플랫폼 호출 프로토타입에 InAttributeOutAttribute를 적용하는 방법을 보여 줍니다. 이러한 방향 특성의 조합을 통해 호출자는 호출 수신자가 변경한 내용을 볼 수 있습니다.

' Declare a class member for each structure element.
< StructLayout( LayoutKind.Sequential, CharSet:=CharSet.Auto )> _
Public Class OpenFileName

   Public structSize As Integer = 0
   Public filter As String = Nothing
   Public file As String = Nothing
   ' ...
   
End Class 'OpenFileName

Public Class LibWrap
   ' Declare managed prototype for the unmanaged function.
   Declare Auto Function GetOpenFileName Lib "Comdlg32.dll" ( _
      <[In], Out> ByVal ofn As OpenFileName ) As Boolean
End Class 'LibWrap
// Declare a class member for each structure element.
[ StructLayout( LayoutKind.Sequential, CharSet=CharSet.Auto )]  
public class OpenFileName 
{
    public int       structSize = 0;
    public string    filter = null;
    public string    file = null;
    // ...
}

public class LibWrap
{
   // Declare a managed prototype for the unmanaged function.
   [ DllImport( "Comdlg32.dll", CharSet=CharSet.Auto )]
   public static extern bool GetOpenFileName([ In, Out ] OpenFileName ofn );  
}
// Declare a class member for each structure element.

[StructLayout(LayoutKind::Sequential,CharSet=CharSet::Auto)]
public ref class OpenFileName
{
public:
   int structSize;
   String^ filter;
   String^ file;
   // ...
};

public ref class LibWrap
{
public:

   // Declare a managed prototype for the unmanaged function.

   [DllImport("Comdlg32.dll",CharSet=CharSet::Auto)]
   static bool GetOpenFileName( [In,Out]OpenFileName^ ofn );
};
// Declare a class member for each structure element.
/** @attribute StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)
 */
public class OpenFileName
{
    public int structSize = 0;
    public String filter = null;
    public String file = null;
    // ...
} //OpenFileName

public class LibWrap
{
    // Declare a managed prototype for the unmanaged function.
    /** @attribute DllImport("Comdlg32.dll", CharSet = CharSet.Auto)
     */
    public static native boolean GetOpenFileName(
        /** @attribute In()
            @attribute Out()
         */
        OpenFileName ofn);
} //LibWrap

상속 계층 구조

System.Object
   System.Attribute
    System.Runtime.InteropServices.InAttribute

스레드로부터의 안전성

이 형식의 모든 public static(Visual Basic의 경우 Shared) 멤버는 스레드로부터 안전합니다. 인터페이스 멤버는 스레드로부터 안전하지 않습니다.

플랫폼

Windows 98, Windows 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

.NET Framework에서 모든 플래폼의 모든 버전을 지원하지는 않습니다. 지원되는 버전의 목록은 시스템 요구 사항을 참조하십시오.

버전 정보

.NET Framework

2.0, 1.1, 1.0에서 지원

.NET Compact Framework

2.0, 1.0에서 지원

참고 항목

참조

InAttribute 멤버
System.Runtime.InteropServices 네임스페이스
OutAttribute
StringBuilder

기타 리소스

Blittable 형식 및 비 Blittable 형식