|
-
Feb 24th, 2005, 04:14 PM
#1
Thread Starter
Junior Member
Equivalent to COleDispatch in VB?
I am trying to figure out how to get some data out of a third party software program into VB. I know that the following C++ code works
long IAutoReader::GetMaxDataIndex()
{
long result;
InvokeHelper(0xc, DISPATCH_METHOD, VT_I4, (void*)&result, NULL);
return result;
}
which is a call to a C++ class called COleDispatch which sucks data out of the program and puts it into a variable which can be assigned in VB, i.e.
Dim lng as Long
lng = IAutoReaderObjectVariable.GetMaxDataIndex() 'works just fine
My question is...can I do something like this in VB? I have looked all over the System.InteropServices namespace and cannot figure it out.
The reason I want to do this is that there is another function in this same C++ library that looks like this.
VARIANT IAutoReader::GetData(long Index, long iStart, long iEnd, double Factor)
{
VARIANT result;
static BYTE parms[] =
VTS_I4 VTS_I4 VTS_I4 VTS_R8;
InvokeHelper(0x18, DISPATCH_METHOD, VT_VARIANT, (void*)&result, parms,
Index, iStart, iEnd, Factor);
return result;
}
Instead of returning a variable type that is directly compatible with VB, it returns a C++ VARIANT which must be referenced with a Object variable type in VB. But the code
Dim obj as Object
obj = IAutoReaderObjectVariable.GetData(2,1,2,.14) 'will not work
The error that I get is :
----------
An unhandled exception of type 'System.Runtime.InteropServices.SafeArrayTypeMismatchException' occurred in mscorlib.dll
Additional information: Specified array was not of the expected type.
------------
My thought is that if I could implement the Ole call to the program directly from VB I could return a variable type that VB could use. The structure may not be the same but as long as I knew the structure I could use the data in my own programs.
Any help that anyone is able to offer would be greatly appreciated.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|