uses comobj;
procedure TMainForm.Button1Click(Sender: TObject);
var WebSite,WebServer:Variant;
begin
try WebSite:=CreateOleObject('IISNamespace'); except Dialogs.MessageDlg('本机可能没有安装IIS系统,接口读取错误!',mtError,[mbOK],0); Exit; end;
WebSite:=WebSite.GetObject('IIsWebService', 'localhost/w3svc');
WebServer:=WebSite.GetObject('IIsWebServer', '1');
WebServer.put('ServerBindings', ':8080:');
WebServer.SetInfo;
end;