抄袭下面网站的内容。没有新意。
http://www.pinvoke.net/default.aspx/httpapi.httpsetserviceconfiguration
public static void AddUrlAcl(string networkURL, string securityDescriptor) { uint retVal = 0; retVal = HttpInitialize(new HTTPAPI_VERSION(1, 0), HTTP_INITIALIZE_CONFIG, IntPtr.Zero); if (0 != retVal) { throw new Win32Exception(Convert.ToInt32(retVal)); } HTTP_SERVICE_CONFIG_URLACL_KEY keyDesc = new HTTP_SERVICE_CONFIG_URLACL_KEY(networkURL); HTTP_SERVICE_CONFIG_URLACL_PARAM paramDesc = new HTTP_SERVICE_CONFIG_URLACL_PARAM(securityDescriptor); HTTP_SERVICE_CONFIG_URLACL_SET inputConfigInfoSet = new HTTP_SERVICE_CONFIG_URLACL_SET(); inputConfigInfoSet.KeyDesc = keyDesc; inputConfigInfoSet.ParamDesc = paramDesc; IntPtr pInputConfigInfo = Marshal.AllocCoTaskMem(Marshal.SizeOf(typeof(HTTP_SERVICE_CONFIG_URLACL_SET))); Marshal.StructureToPtr(inputConfigInfoSet, pInputConfigInfo, false); retVal = HttpSetServiceConfiguration( IntPtr.Zero, HTTP_SERVICE_CONFIG_ID.HttpServiceConfigUrlAclInfo, pInputConfigInfo, Marshal.SizeOf(inputConfigInfoSet), IntPtr.Zero); Marshal.FreeCoTaskMem(pInputConfigInfo); HttpTerminate(HTTP_INITIALIZE_CONFIG, IntPtr.Zero); if (0 != retVal) { throw new Win32Exception(Convert.ToInt32(retVal)); } }