httpdeleteserviceconfiguration (httpapi)
Last changed: markg@microsoft.com-131.107.71.96

.
Summary
The HttpDeleteServiceConfiguration function deletes specified information, such as IP addresses or SSL Certificates, from the HTTP API configuration store, one record at a time.

C# Signature:

[DllImport("httpapi.dll", SetLastError = true)]
static extern uint HttpDeleteServiceConfiguration(
     IntPtr ServiceIntPtr,
     HTTP_SERVICE_CONFIG_ID ConfigId,
     IntPtr pConfigInformation,
     int ConfigInformationLength,
     IntPtr pOverlapped);

VB Signature:

Declare Function HttpDeleteServiceConfiguration Lib "httpapi.dll" (TODO) As TODO

User-Defined Types:

HTTP_SERVICE_CONFIG_ID

HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM

HTTP_SERVICE_CONFIG_SSL_KEY

HTTP_SERVICE_CONFIG_URLACL_SET

Notes:

Depending on the value of ConfigId, pConfigInformation should point to a different type of structure. If it wasn't for this, I could redifine the PInvoke signature to explicitly specify the underlying structure type.

ConfigId Value ConfigInformation Structure Type
HttpServiceConfigIPListenList HTTP_SERVICE_CONFIG_IP_LISTEN_PARAM structure.
HttpServiceConfigSSLCertInfo HTTP_SERVICE_CONFIG_SSL_KEY structure.
HttpServiceConfigUrlAclInfo HTTP_SERVICE_CONFIG_URLACL_SET structure.

Tips & Tricks:

If your use of this API is focused around a single value of ConfigId, you may want to change the IntPtr (pConfigInformation) to point directly to a managed version of the correct underlying structure and let the default marshaller take care of the interop layer marshaling for you (and your memory management).

Sample Code:

void FreeURL(string networkURL, string securityDescriptor)
{
     uint retVal = (uint) ErrorCodes.NOERROR;

     retVal = HttpApi.HttpInitialize(HttpApi.HTTPAPI_VERSION, HttpApi.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
     if ((uint) ErrorCodes.NOERROR == retVal)
     {
     HTTP_SERVICE_CONFIG_URLACL_KEY urlAclKey = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL);
     HTTP_SERVICE_CONFIG_URLACL_PARAM urlAclParam = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor);

     HTTP_SERVICE_CONFIG_URLACL_SET urlAclSet = new HTTP_SERVICE_CONFIG_URLACL_SET();
     urlAclSet.KeyDesc = urlAclKey;
     urlAclSet.ParamDesc = urlAclParam;

     IntPtr configInformation = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET)));
     Marshal.StructureToPtr(urlAclSet, configInformation, false);
     int configInformationSize = Marshal.SizeOf(urlAclSet);

     retVal = HttpApi.HttpDeleteServiceConfiguration(IntPtr.Zero,
         HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo,
         configInformation,
         configInformationSize,
         IntPtr.Zero);

     Marshal.FreeCoTaskMem(configInformation);

     HttpApi.HttpTerminate(HttpApi.HTTP_INITIALIZE_CONFIG, IntPtr.Zero);
     }

     if ((uint) ErrorCodes.NOERROR != retVal)
     {
     throw new Win32Exception(Convert.ToInt32(retVal));
     }
}

Alternative Managed API:

Do you know one? Please contribute it!

Documentation