WbemScripting.SWbemLocator オブジェクトを使用して IIsWebServer の Properties_ プロパティを列挙しようとしています。私の目標は、PascalScript コードを使用して Web サイトのサーバー バインディングを取得することです。VBScript には、次のコードがあります。
Dim site, binding, url
Set site = GetObject("IIS://localhost/W3SVC/1")
For Each binding In site.ServerBindings
url = binding
Exit For
Next
If Left(url, 1) = ":" Then
url = "localhost" & url
End If
If Right(url, 1) Then
url = Left(url, Len(url) - 1)
End If
Set site = Nothing
このコードはフリーハンドで書いたので正確ではないかもしれませんが、同様の方法で PascalScript で実行したいと考えています。私が立ち往生している部分は、ServerBindings を列挙することです。私はそれを機能させるために多くのことを試みましたが、現在の時点では、次の PascalScript があります。
function GetWebSites() : Array of String;
var
locatorObj, providerObj, nodeObj, appRoot: Variant;
props : String;
begin
locatorObj := CreateOleObject('WbemScripting.SWbemLocator');
providerObj := locatorObj.ConnectServer(GetComputerNameString(), 'root/MicrosoftIISv2');
nodeObj := providerObj.Get('IIsWebServer=''W3SVC/1''');
props := nodeObj.Properties_;
// How do I enumerate through the properties here? Or, my actual goal is from this point how do I get the ServerBindings (or the first element in the ServerBindings array)?
終わり;
JavaScript で ServerBindings を取得するには、次のようなものを使用する必要があります。
var e = new Enumerator(nodeObj.Properties_);
for (; ! e.atEnd(); e.moveNext()) {
var prop = e.item();
if (prop.Name == 'ServerBindings') {
// Do something
}
}
どんな助けでも大歓迎です。ありがとうございました。