다음 절차에서는 클라이언트별 경로 목록을 사용하는 단계를 간략하게 설명합니다. 다음 샘플 코드는 프로시저를 구현하는 방법을 보여 줍니다.
이 기능을 사용하려면 클라이언트에서 다음 단계를 수행해야
- RtmCreateRouteList 호출하여 라우팅 테이블 관리자에서 핸들을 가져옵니다.
- 클라이언트가 이 목록에 경로를 추가해야 할 때마다 RtmInsertInRouteList 호출합니다.
- 클라이언트에 목록이 더 이상 필요하지 않은 경우 RtmDeleteRouteList 호출하여 목록을 제거해야 합니다.
클라이언트가 목록의 경로를 열거해야 하는 경우 클라이언트는 다음 단계를 수행해야
- RtmCreateRouteListEnum 호출하여 라우팅 테이블 관리자에서 열거형 핸들을 가져옵니다.
- RtmGetListEnumRoutes 호출하여 목록의 경로에 대한 핸들을 가져옵니다.
- 더 이상 필요하지 않은 경우 RtmReleaseRoutes 호출하여 핸들을 해제합니다.
다음 샘플 코드는 클라이언트별 경로 목록을 만들고 사용하는 방법을 보여줍니다.
HANDLE RouteListHandle1;
HANDLE RouteListHandle2;
// Create two entity-specific lists to add routes to
Status = RtmCreateRouteList(RtmRegHandle,
&RouteListHandle1);
// Check Status
//...
Status = RtmCreateRouteList(RtmRegHandle,
&RouteListHandle2);
// Check Status
//...
// Assume you have added a bunch of routes
// by calling RtmAddRouteToDest many times
// with 'RouteListHandle1' specified similar to
// Status = RtmAddRouteToDest(RtmRegHandle,
// ...
// RouteListHandle1,
// ...
// &ChangeFlags);
// Enumerate routes in RouteListHandle1 list
// Create an enumeration on the route list
Status = RtmCreateRouteListEnum(RtmRegHandle,
RouteListHandle1,
&EnumHandle);
if (Status == NO_ERROR)
{
// Allocate space on the top of the stack
MaxHandles = RegnProfile.MaxHandlesInEnum;
RouteHandles = _alloca(MaxHandles * sizeof(HANDLE));
// Note how the termination condition is different
// from other enumerations - the call to the function
// RtmGetListEnumRoutes always returns NO_ERROR
// Quit when you get fewer handles than requested
do
{
// Get next set of routes from the list enumeration
NumHandles = MaxHandles;
Status = RtmGetListEnumRoutes(RtmRegHandle,
EnumHandle,
&NumHandles,
RouteHandles);
for (i = 0; i < NumHandles; i++)
{
Print("Route Handle %5lu: %p\n", i, RouteHandles[i]);
}
// Move all these routes to another route list
// They are automatically removed from the old one
Status = RtmInsertInRouteList(RtmRegHandle,
RouteListHandle2,
NumHandles,
RouteHandles);
// Check Status...
// Release the routes that have been enumerated
RtmReleaseRoutes(RtmRegHandle, NumHandles, RouteHandles);
}
while (NumHandles == MaxHandles);
RtmDeleteEnumHandle(RtmRegHandle, EnumHandle);
}
// Destroy all the entity-specific route lists
// after removing all routes from these lists;
// the routes themselves are not deleted
Status = RtmDeleteRouteList(RtmRegHandle, RouteListHandle1);
ASSERT(Status == NO_ERROR);
Status = RtmDeleteRouteList(RtmRegHandle, RouteListHandle2);
ASSERT(Status == NO_ERROR);