1
我正尝试端口下面的JavaScript代码来INNO-设置Pascal脚本:无法转换类型(未知)的变体进入式(调度)
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.AdminManager');
var appPoolsSection = adminManager.GetAdminSection('system.applicationHost/applicationPools', 'MACHINE/WEBROOT/APPHOST');
var appPoolsCollection = applicationPoolsSection.Collection;
for (var i = 0; i < appPoolsCollection.Count; i++)
{
var appPool = appPoolsCollection.Item(i);
// doing someting with the application pool
}
此代码已被翻译成这样:
var AdminManager, AppPoolsSection, AppPoolsCollection, AppPool: Variant;
i: Integer;
begin
AdminManager := CreateOleObject('Microsoft.ApplicationHost.AdminManager');
AppPoolsSection := AdminManager.GetAdminSection('system.applicationHost/applicationPools', 'MACHINE/WEBROOT/APPHOST');
AppPoolsCollection := AppPoolsSection.Collection;
for i := 0 to AppPoolsCollection.Count-1 do begin
AppPool := AppPoolsCollection.Item(i);
// doing someting with the application pool
end;
end;
但它是提高在线AppPoolsCollection := AppPoolsSection.Collection
以下错误:
Exception: Could not convert variant of type (Unknown) into type (Dispatch).
有任何事情我可以做的是通知pascal scritp AppPoolsSection
对象是IDispach
而不仅是IUnknown
?
你['IAppHostAdminManager :: GetAdminSection'](http://msdn.microsoft.com/en-us/library/aa965186(V = VS.90)。 aspx)方法调用对我来说看起来很奇怪。它应该有3个参数,其中第三个参数是'AppPoolsSection'变量和'HRESULT'类型的结果。看起来你的代码在将'HRESULT'值传递给'AppPoolsSection'变量时失败了,假设它以后是一个集合。 – TLama
正是从[这里]的JavaScript例的直接端口(http://www.iis.net/configreference/system.applicationhost/sites)。我将使用接口声明来处理它。谢谢。 –