Freigeben über


Obtaining the Buffer Size (Windows CE 5.0)

Send Feedback

Many of the IP Helper functions work similarly. To retrieve the table of data which you are requesting, you need to know how large a buffer to pass. So the function is first called with a null buffer and a pointer to a location for the required buffer size. The function is then called with the appropriate buffer size. This is shown in the code snippet below.

// Get the Network Parameters
//Note that this code snippet can also be used 
//for other 'get' functions, such as GetTcpStatistics, 
//GetIpAddrTable, and so on.
PFIXED_INFO pNetworkParams = NULL;
ULONG uSizeNetworkParams = 0;
DWORD status;

// Find out how large the buffer needs to be to hold the data
status = GetNetworkParams(pNetworkParams, &uSizeNetworkParams);
if (status == ERROR_BUFFER_OVERFLOW) {
   // Allocate a buffer of the appropriate size
   if (!(pNetworkParams = (PFIXED_INFO) malloc(uSizeNetworkParams))) {
      return(1);
   }
   // Obtain Adapter Info
   status = GetNetworkParams(pNetworkParams, &uSizeNetworkParams);
}

See Also

IP Helper Code Samples

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.