Passing arguments ByRef from VBScript to COMAdmin component 
Author Message
 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



Fri, 15 Jul 2005 17:48:36 GMT  
 Passing arguments ByRef from VBScript to COMAdmin component
Doesn't look VBScript friendly to me.  VBScript can't coerce a variant
argument to a strongly typed (i.e., non-variant) byref method parameter.

You don't control the source of the COM method in question, but the
following KB articles describe how the authors *should* have done it to make
it VBScript friendly...

Q197957 - PRB: Passing Parameters By Reference to a VC COM Object
http://support.microsoft.com/default.aspx?kbid=197957

Q197956 - PRB: Passing Parameters By Reference to a VB COM Object
http://support.microsoft.com/default.aspx?kbid=197956

Q174576 - HOWTO: Return Arrays from Server-Side Objects in ASP
http://support.microsoft.com/default.aspx?kbid=174576

Q218454 - HOWTO: Implement Array Arguments in Visual C++ COM Objects for
Active Server Pages
http://support.microsoft.com/default.aspx?kbid=218454

Q217114 - HOWTO: Implement Array Arguments in Visual Basic COM Objects for
Active Server Pages
http://support.microsoft.com/default.aspx?kbid=217114

Type Mismatch When Passing Parameters from ASP to VB
http://support.microsoft.com/default.aspx?kbid=165967

--
Michael Harris
Microsoft.MVP.Scripting
Seattle WA US



Sat, 16 Jul 2005 08:36:10 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Passing arguments ByRef to Script Control 1.0

2. Pass arguments ByVal or ByRef

3. Passing arguments byref to a class

4. Property Let argument ByRef is NOT ByRef ?

5. VBScript ByRef argument to VB DLL in IIS-5

6. Passing optional object arguments from COM components

7. How to pass vbscript array variable to shared object using ByRef

8. Passing arguments with custom events to HTML(VBScript)

9. asp/vbscript/vb optional procedure arguments not passed....

10. JScript, Event Interfaces, and ByRef arguments

11. ByRef arguments

12. Arguments : Passing Arguments containing <">

 

 
Powered by phpBB® Forum Software