Favicon

Extern modifier

Peponi11/27/20241m

C#
SyntaxKeywordModifier

1. Introduction

extern 한정자는 외부 메서드를 선언하는 데 사용한다. 이 때, 메서드는 반드시 static으로 선언되어야 한다.

2. Example

// SysWow64 리다이렉트 중지
[DllImport("kernel32.dll")]
static extern bool Wow64DisableWow64FsRedirection(ref IntPtr ptr);
 
// SysWow64 리다이렉트 재개
[DllImport("kernel32.dll")]
static extern bool Wow64RevertWow64FsRedirection(IntPtr ptr);
 
[DllImport("MyDll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern bool Open(IntPtr handle, StringBuilder openPath, uint bufferSize);

3. 참조 자료