Click here to Skip to main content
15,891,704 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Everyone, I'm a bit new to this world. pls help

Here's the code that is to be put into VB Dll

VB
Public Interface ISATExperionPCPlugin
    Function StartAudit(ByVal inputFile As String) As Integer
End Interface
Public Class Exp
    Implements ISATPCPlugin    
    Public Function GetInterface(ByVal interfaceType As Integer, <MarshalAsAttribute(UnmanagedType.IDispatch)> ByRef ppvs As Object) As Integer Implements ISATCommonPlugin.GetInterface
        Dim abc As ISATPCPlugin = New Exp

       '    <need the="" code="" here=""> <need to="" assign="" the="" address="" of="" abc="" ppvs="" so="" that="">
       '                          ppvs->StartAudit(...) can be called from COM>
    
    End Function
    Public Function StartAudit(ByVal inputFile As String) As Integer Implements                          ISATPCPlugin.StartAudit

    End Function
End Class</need></need>


and code in COM,
COM
ptrISATPCPlugin->GetInterface(&pluginType,(&IDispatch)**ppvs);
// need the address of abc in ppvs

what can I do in VB Dll function GetInterface(... ) so that ppvs contains the address of abc which is an object of the class Exp in which GetInterface(... ) is implemented. If it can be done, then I can call ppvs->StartSudit(... ) can be called directly from the COM.


Experts please help...
Posted

1 solution

You need to create an object instance in your VB code that implements ISATExperionPCPlugin the interface.
you can create the instance in side GetInterface function.

then in ppv you assign the address of the object instance you created and type cast the instance as ISATExperionPCPlugin*

This is very basic implementation of your GetInterface function.

You can add different logic to your requirement.

Before assiging addess to ppv check the interfaceType also.
 
Share this answer
 
Comments
ArjunHatwar 18-Jul-11 4:20am    
sorry, It's by mistake. it is ISATPCPlugin not ISATExperionPCPlugin
and have created the object too

Dim abc As ISATPCPlugin = New Exp // Here Exp implements ISATPCPlugin
now how can I make ppvs point to abc?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900