Home > Software engineering >  Vb how to pass the callback interface pointer
Vb how to pass the callback interface pointer

Time:10-09

I com file written in vb loading a c + +, there is now a function requires to callback interface pointer, always quote type does not match, please help to look at, com idl are defined as follows:
The library BIZCOMLib
{
Stdole32. TLB importlib (" ");
Stdole2. TLB importlib (" ");


Uuid (715 f4705 - D954-4942 - AF67 - A480D356ACBA),
ENTRFUNC helpstring (" Class ")
]
Coclass ENTRFUNC
{
[default] interface IENTRFUNC;
[the source, the default] interface ICallBack;
Call a function:
[id (4), helpstring (" method "ENTRFUNC_Init)] HRESULT ENTRFUNC_Init ([in] the VARIANT use_ssl, [in] the VARIANT start_conn, [in] ICallBack * pCallBack, [in] the VARIANT * parg);
Vb call methods:
Private Sub CommandButton2_Click ()
Dim myobject As Object
The Set myobject=Nothing
The Set myobject=CreateObject (" BIZCOM. ENTRFUNC ")
Call myobject. ENTRFUNC_TASInit (1)
Call myobject. ENTRFUNC_Init (0, 1, myobject, 0)
End Sub

The ICallBack * pCallBack in vb how to define

CodePudding user response:

Defined as long
Callback function code should be placed in the module cannot be put before the argument in the form with the function name and AddressOf limit

CodePudding user response:

Warrior can give a code example that I vb level generally

CodePudding user response:

In addition, I am not this is to load the com DLL, function also need to redefine

CodePudding user response:

This I also say bad, com interface don't know what will be the VB marked as unknow, in that case may make uncertain, safer if defined as long type


VB under, should be like a DLL, Call myobject. Myfunction. A, b, c,... The AddressOf MyCallBackFun

MyCallBackFun to define in the module file

CodePudding user response:

Also, if you com components is do it yourself, after all, I think would be better to make events, the callback is not in conformity with the VB style
You in VB menu "engineering" & gt; & gt;" Quote "can be found at the bottom of their com component, select the
Then you can be declared in the form of a Private WithEvents myobject As BIZCOM. ENTRFUNC
So you can choose to the events in this component.

CodePudding user response:

Dim myobject As Object
If such a definition in a module also not line,
Addressof function is, the process, you pass an object pointer right in the past
  • Related