
Passing arguments ByRef from VBScript to COMAdmin component
hi
i'm using the COMAdmin library from
VBScript to perform various
component installation and configuration, and for the most part, is
working perfectly.
however, i'm wanting to use the COMAdminCatalog's QueryApplicationFile
method, which returns various attributes about a COM+ MSI application
file.
from VB (not vb script) this method's interface looks like this:
Sub QueryApplicationFile(bstrApplicationFile As String,
bstrApplicationName As String, bstrApplicationDescription As
String,
bHasUsers As Boolean, bIsProxy As Boolean, varFileNames() As
Variant)
from VB i can call it like this:
Dim strQAApplicationName As String
Dim strQAApplicationDescription As String
Dim bQAHasUsers As Boolean
Dim bQAIsProxy As Boolean
Dim varQAFileNames() As Variant
oCAdminCatalog.QueryApplicationFile(sFilePath,
strQAApplicationName,
strQAApplicationDescription, bQAHasUsers, bQAIsProxy,
varQAFileNames)
where sFilePath specifies the application file, and all the other
parameters are return parameters. this works fine, and returns all
the expected values.
however, the same code (without the type names, of course) fails in VB
Script with error 13 (Type mismatch). i don't know exactly which
ByRef parameter the call is failing on, alhought i'm suspecting either
the variant array or the strings.
the COMAdmin.COMAdminCatalog component's IDL looks like this:
interface ICOMAdminCatalog : IDispatch {
...
HRESULT QueryApplicationFile(
[in] BSTR bstrApplicationFile,
[out] BSTR* bstrApplicationName,
[out] BSTR* bstrApplicationDescription,
[out] VARIANT_BOOL* bHasUsers,
[out] VARIANT_BOOL* bIsProxy,
[out] SAFEARRAY(VARIANT)* varFileNames);
...
Quote:
};
i've tried changing the variant array declaration in VBScript to a
single variant rather than a variant array of variants, ie. removed
the () brackets. this results in the same error. likewise,
predeclaring an array size (eg. 255) also results in the same error.
could anyone shed any light on what precisely is going wrong here, and
how i might be able to call this method from VBScript? i'd rather
avoid having to write my own COM wrapper, but am prepared to do so if
necessary.
thanks in advance
Roland