Quantcast
Channel: VBForums - API
Viewing all articles
Browse latest Browse all 168

What exactly are the parameters for the API method called DispCallFunc?

$
0
0
Looking at MSDN I see
Code:

HRESULT DispCallFunc(
  void      *pvInstance,
  ULONG_PTR  oVft,
  CALLCONV  cc,
  VARTYPE    vtReturn,
  UINT      cActuals,
  VARTYPE    *prgvt,
  VARIANTARG **prgpvarg,
  VARIANT    *pvargResult
);

Some of these are confusing, because they don't specify a byte-size for the parameter, but instead give it in some cryptic way that is great for VC++, but not so great for those wanting to figure out how to use it in VB6.

For example, what is a "void"? I thought it meant "don't fill in this parameter, because it's unused", but I'm not sure. Some are obvious like ULONG_PTR, means an unsigned long value which holds a memory address (a pointer). VB6 doesn't have any unsigned Long, but it has the standard (signed) Long, which should usually work. Other cryptic ones are VARTYPE. What type of variable is a VARTYPE? Is it equivalent to a Long in VB6? Or is it the equivalent to an Integer in VB6 (what VC++ calls a Short)?

And for goodness sake, what is a VARIANTARG? I think (based on some other things I've read), this is where I feed some pointers to the input parameters to the function that is to be called, to the DispCallFunc method. But what kind of input is it expecting?
Is it expecting an array of Long values that are pointers? Is it expecting a Variant that holds an array of Long values that are pointers? Is it expecting an array of Variants that hold Long values that are pointers? Or is it expecting a Variant that holds an array of Variants that hold Long values that are pointers?

Any help here at using this in VB6 would be great. There are hardly any examples on the net that show its use at all (even in C based languages), and from what I can tell, there are none that show its use in VB6.

I wish there was just some tutorial that said "These are the data types of the parameters of the DispCallFunc method, and here's what the function expects you to put into them. ......". But nope, nothing of the sort. Can somebody here on VbForums just explain straight out, what is the correct declare statement for this thing, and how do I use it to call a variety of different methods in my Module1 module? Some things I'd like to know how to use it with are:
A function with no input parameters, but with an output parameter (like maybe a random number generator).
A function with some input parameters, and a return value.
A sub with some input parameters, and no return value.
A sub with no input parameters, and no return value (but maybe it does something else, like clear the screen)
Calling a function or sub that is not in my Module1 module, but rather in an STDCALL DLL file.
Calling a function or sub that is not in my Module1 module, but rather in an CDECL DLL file.
Calling a function or sub that is in a COM object (such as from an ActiveX DLL or OCX file)
Calling a function or sub that is in a VB6 Class (such as a method in Class1)

Any help with its general use (like how to properly declare it, and what the parameters mean), and any help for these specific listed uses from someone who's an expert at using DispCallFunc, would be very helpful.

Viewing all articles
Browse latest Browse all 168

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>