if ADsGetObject('IIS://localhost/w3svc', IID_IADsContainer, IUnknown(I)) = S_Ok then
begin
//create a new virtual server at the service
ServerObj := IADs(I.Create('IIsWebServer', aaa));//aaa是一个数字
//configure new server
ServerObj.Put('ServerSize', 1);
// Medium-sized server
ServerObj.Put('ServerComment', edComment.text);、、这个是描述
// ServerObj.put('ServerBindings', edIPAddress.text + ':' + edPort.text + ':');
// Write info back to Metabase edIPAddress.text 是IP地址,edPort.text 是端口号
ServerObj.put('ServerBindings', ':80:');
ServerObj.SetInfo;
if ServerObj.QueryInterface(IID_IADsContainer, I) = S_OK then
begin
//create virtual root directory
ADs := IADs(I.Create('IIsWebVirtualDir', 'Root'));
//Configure new virtual root
ADs.put('Path', edCommentPath.Text);//是站点的路径
ADs.put('AccessRead', 'True');//设置权限
ADs.put('AccessScript', 'True');
ADs.put('EnableDefaultDoc', 'True');//设置是否允许默认文档
//Configure Default do
cument as "index.asp"
ADs.put('DefaultDoc', 'index.asp');
//ADs.put('EnableDirBrowsing','F');
//Write info back to Metabase
ADs.SetInfo;
(ADs as IISApp).AppCreate(true);
end;
end;
之前要导入ActiveDs_TLB, IISExt_TLB库,也就是导入adsi的那几个库