본문 바로가기
코드/kernel

LIST_ENTRY 사용

by WeZZ 2009. 11. 26.



/*******************************************************************************
linked list
********************************************************************************/

typedef struct _ListHandle {
 LIST_ENTRY link;
 HWND  hWnd;
}ListHandle, *PListHandle;

 

LIST_ENTRY g_handleList;

 

 

/*******************************************************************************

초기화
********************************************************************************/

InitializeListHead(&g_handleList);

 

/*******************************************************************************

리스트에 넣기
********************************************************************************/

PListHandle entry;
entry = (PListHandle)malloc(sizeof(ListHandle));
entry->hWnd = pMsg->hWnd;
InsertTailList(&g_handleList, &entry->link);

 

/*******************************************************************************

리스트에서 가져오기
********************************************************************************/

if(!IsListEmpty(&g_handleList))
{
       PLIST_ENTRY PList_temp = g_handleList.Flink;
       PListHandle tmp = NULL;
       do{
             tmp = CONTAINING_RECORD(PList_temp, ListHandle, link);
             SendMessage(tmp->hWnd, WM_COPYDATA, pMsg->uMsgType, (LPARAM)&cp);
             PList_temp = PList_temp->Flink;
       }while(PList_temp != &g_handleList);
}

 

/*******************************************************************************

엔트리 삭제
********************************************************************************/

//해당 엔트리 삭제

RemoveEntryList(&g_handleList->Flink);

 

 //리스트에서 맨앞 엔트리 하나 삭제

RemoveHeadList(&g_handleList);

 

 //리스트에서 맨뒤 엔트리 하나 삭제

RemoveTailList(&g_handleList);