Call now: (800) 766-1884  


 SQL Server Tips
 SQL Server Training

 SQL Server Consulting
 SQL Server Support
 SQL Server Remote DBA

 SQL Server Scripts
 Scripts Menu





SQL Server

SQL Server Tips by Gama and Naughter Consulting


IP Helper

The IP Helper API is part of the Microsoft SDK and it has three main uses:
     * Get configuration settings for the local computer.
     * Modify configuration settings for the local computer.
     * Trigger events that notify applications of changes in the configuration settings for the local computer.

The code uses a method named NibbleToChar, which converts nibbles (4-bit blocks) to hexadecimal values, returned as the integer ASCII code corresponding to the hexadecimal character. This method will be used when one byte is to be converted to its hexadecimal representation, one nibble at a time.
This is the method NibbleToChar:

char CIPConfigExtendedStoredProcedure::NibbleToChar(int Nibble)
if (Nibble >= 0 && Nibble < 10)
return (char) (Nibble + '0');
else if (Nibble < 16)
return (char) (Nibble - 10 + 'A');
return '?';

The boolean variable bVerbose will be true if the input parameter "verbose" is set. It will be used to determine whether certain data will be displayed or not:

BOOL bVerbose = FALSE;
if (m_pParameterData[VERBOSE_PARAMETER_INDEX].m_bType != SRVNULL)
bVerbose = (XP_INT4(m_pParameterData[VERBOSE_PARAMETER_INDEX].m_Data) != 0);

A call to GetAdaptersInfo with a NULL pointer will retrieve the size of the buffer required for storing the data:

ULONG nOutputBufferSize = 0;
DWORD dwError = GetAdaptersInfo(NULL, &nOutputBufferSize);

The variable dwError will store the return value from the function and it will be different from zero if there was an error.
The next step is to allocate the right amount of space for the buffer before calling GetAdaptersInfo again but this time with a pointer to an IP_ADAPTER_INFO structure. This will retrieve information about all the adapters as a linked list of IP_ADAPTER_INFO structures.

PIP_ADAPTER_INFO pAdaptersInfo = (PIP_ADAPTER_INFO) _alloca(nOutputBufferSize);
dwError = GetAdaptersInfo(pAdaptersInfo, &nOutputBufferSize);

The network parameters can be retrieved now with a call to GetNetworkParams, just like before, the first call is to get the size of the buffer:

nOutputBufferSize = 0;
dwError = GetNetworkParams(NULL, &nOutputBufferSize);

The following code will allocate the necessary space for the buffer and retrieve the network parameters:

PFIXED_INFO pFixedInfo = (PFIXED_INFO) _alloca(nOutputBufferSize);
dwError = GetNetworkParams(pFixedInfo, &nOutputBufferSize);

The columns in the recordset to be returned are described next:

Describe(1, "Attribute", SRV_NULLTERM, SRVVARCHAR, 255, SRVVARCHAR, 255, NULL);
Describe(2, "Value", SRV_NULLTERM, SRVVARCHAR, 255, SRVVARCHAR, 255, NULL);

These columns will store the network parameters and the properties of each adapter. Assuming verbose listing, this is the Host Name parameter:

char* pszHostName = "";
SetColumnLength(1, (int) strlen(pszHostName));
SetColumnData(1, pszHostName);
SetColumnLength(2, (int) strlen(pFixedInfo->HostName));
SetColumnData(2, pFixedInfo->HostName);

The network parameters are the same for all adapters, therefore they will only show up once, followed by the properties of each adapter.

The above book excerpt is from:

Super SQL Server Systems
Turbocharge Database Performance with C++ External Procedures

ISBN: 0-9761573-2-2
Joseph Gama, P. J. Naughter




Burleson Consulting Remote DB Administration







Burleson is the America's Team

Note: The pages on this site were created as a support and training reference for use by our staff of DBA consultants.  If you find it confusing, please exit this page.

Errata?  SQL Server technology is changing and we strive to update our SQL Server support information.  If you find an error or have a suggestion for improving our content, we would appreciate your feedback.  Just  e-mail:and include the URL for the page.

Burleson Consulting
SQL Server database support


Copyright 1996 -  2013 by Vaaltech Web Services. All rights reserved.

Hit Counter