LIST_ENTRY使用

 

VOID LinkListTest()

{

       LIST_ENTRY linkListHead;

       //初始化链表

       InitializeListHead(&linkListHead);

 

       PMYDATASTRUCT pData;

       ULONG i = 0;

       //在链表中插入10个元素

       KdPrint(("Begin insert to link list"));

       for (i=0 ; i<10 ; i++)

       {

              pData = (PMYDATASTRUCT)

                     ExAllocatePool(PagedPool,sizeof(MYDATASTRUCT));

              pData->number = i;

              InsertHeadList(&linkListHead,&pData->ListEntry);

       }

 

       //从链表中取出,并显示

       KdPrint(("Begin remove from link list\n"));

       while(!IsListEmpty(&linkListHead))

       {

              PLIST_ENTRY pEntry = RemoveTailList(&linkListHead);

              pData = CONTAINING_RECORD(pEntry,

                              MYDATASTRUCT,

                              ListEntry);

              KdPrint(("%d\n",pData->number));

              ExFreePool(pData);

       }

 }

 

遍历

PLIST_ENTRY pLink=NULL;
 for(pLink = glinkListRule.Flink; pLink !=(PLIST_ENTRY) &glinkListRule.Flink; pLink = pLink->Flink)
 {
  pRegPrtRule pData= CONTAINING_RECORD(pLink,RegPrtRule,ListEntry);
  
 }

posted @ 2009-02-12 22:28  ahuo  阅读(2168)  评论(0编辑  收藏  举报