抄袭下面网站的内容。没有新意。
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));
}
}
本文详细介绍了如何使用HTTPAPI函数集配置服务URLACL,包括初始化、设置配置信息、终止连接等步骤。

被折叠的 条评论
为什么被折叠?



