VB :: Code & APIs

[VB.NET] 공용체 (Union) 선언하기

어느 날 공용체 선언할 일이 생겨서 조금 삽질하다보니 다음과 같이 공용체 선언이 가능하더군요.
C# 에서도 적용되는 것 같으니 참고하시면 되겠습니다…^^

예를 들어 이러한 구조체를 선언할 때는…

   <StructLayout(LayoutKind.Sequential)> _
    Private Structure DEBUG_EVENT
        Public dwDebugEventCode As Int32
        Public dwProcessId As Int32
        Public dwThreadId As Int32
        <StructLayout(LayoutKind.Explicit)> _
        Public Structure u
            <FieldOffset(0)> Public Exception As EXCEPTION_DEBUG_INFO
            <FieldOffset(0)> Public CreateThread As CREATE_THREAD_DEBUG_INFO
            <FieldOffset(0)> Public CreateProcessInfo As CREATE_PROCESS_DEBUG_INFO
            <FieldOffset(0)> Public ExitThread As EXIT_THREAD_DEBUG_INFO
            <FieldOffset(0)> Public ExitProcess As EXIT_PROCESS_DEBUG_INFO
            <FieldOffset(0)> Public LoadDll As LOAD_DLL_DEBUG_INFO
            <FieldOffset(0)> Public UnloadDll As UNLOAD_DLL_DEBUG_INFO
            <FieldOffset(0)> Public DebugString As OUTPUT_DEBUG_STRING_INFO
            <FieldOffset(0)> Public RipInfo As RIP_INFO
        End Structure
    End Structure

이렇게 사용하실 수 있습니다.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: