07-09-2005 09:50 AM
07-13-2005 03:04 AM
VARIANT Val; ::VariantInit(Val); V_VT(&Vargs[i]) = VT_BYREF | VT_VARIANT V_VARIANTREF(&Vargs[i]) = &Val;
07-14-2005 03:13 AM
07-14-2005 04:14 AM
Hi diadev,
I looked in the DIAdem documentation for ValueRangeGet and ChnLengthGet, and they are both the kinds of functions that I would expect to take by ref variants as I described in my first post. The actual return value is used for a success code and the information you want gets placed in a VARIANT that you pass in. VBScript does this for you automatically which is why this is so much easier under VBS.
Unfortunately, I'm not familiar with your library. I hope you have the source code for it. It looks like it takes a variable length list of parameters and the string after the method name says which parameters are coming. This is probably the information that it uses to pack the dispparams together. Possibly that function does not have support for by ref variants or has a bug in dealing with them, but since I don't know the function I can't say for sure. If I were you, I'd debug into that function and see how it does the actual packing of the arguments for it's call to IDispatch->Invoke.
As far as the ref counting of the dispatch map goes, I can't say much. I do know that the couple of times I've "pulled" the DIAdem dispatch map that I haven't had reference leaks, or that if I have had them that I eventually found the problem in my own code. But I've also never called these particular functions. Again, you may want to debug into your library and see what it actually does with the dispatch pointer that you pass into it.
You can also check for relationships between the ref count and the things you do with the dispatch map. Release returns the current refcount. Using that, you will at least be able to determine which object it is that is not properly reference counted. If the ref count seems to be proportional to the number of calls to your Invoke function, then that is a strong indicator that the problem lies somewhere in the Invoke function. Otherwise try to find a relationship between the number of leaked references and some other action you perform in your code. Don't forget that QueryInterface also increments the reference count while you're checking.
I hope that helps,
Myrle
P.S. The problem with making examples for C programmers is that then you have to support them. And someone who's good enough in C to support a C programmer is usually a C programmer himself and not in support. 🐵
08-17-2005 03:05 AM
08-17-2005 02:36 PM
Hello diadev,
Looks like Myrle has already answered most of your questions. If you want to find the channel number from the channel name, here is what you can do :
use "nDIAdemVarGet" which is designed to get the value of a variable. Instead of referring to a variable directly, you send "CNO(<channelname>)" to use the DIAdem function CNo to convert from channel name to number. The return value from nDIAdemVarGet will give you the number..
One thing I'd like to ask is whether you can describe the use case for your GPI DLL. Are you trying to import the data from a file ? If so, DataPlugins may be a better alternative. Just let me know whether you would like to get more information.
Andreas
08-18-2005 02:45 AM