|
-
Nov 28th, 2000, 12:03 PM
#1
Thread Starter
New Member
I have a C++ COM DLL Server and a VB client.
The VB client tries to access a method in an interface
implemented in the DLL Server but as best I can tell it
will not work because the method has more than 1 parameter.
Any ideas?
Partial VB listing
'C++ COM DLL Server
Dim WithEvents AcqMgr As HunterAcqMgrLib.HComSensorAcqMgr
Private Sub Form_Load()
Dim iResult As Integer
Set AcqMgr = New HComSensorAcqMgr
Dim s As HESamExecuteFreq
' Intellisense brings up possible selections
s = KSamExecRepeat6Hz
Dim t As HESamSeqType
' Intellisense brings up possible selections
t = KSamSeqTypeAlign
Dim u As HESamMode
' Intellisense brings up possible selections
u = KSamModeAlignSummary
' If I change AddMessageToQ in the C++ COM DLL Server so
' that it only takes 1 parameter, it will compile. Any
' method that takes more than 1 parameter does not work.
'Does not work
AcqMgr.AddMessageToQ(KSamSeqTypeAlign,KSamExecRepeat6Hz,bActive,KSamModeAlignSummary)
'Does not work
AcqMgr.AddMessageToQ(t,s,False,u)
'Does not work
AcqMgr.AddMessageToQ(0, 4, False, 1)
'Works
AcqMgr.ChangeSamMode (KSamModeIdle)
End Sub
The C++ idl looks like
[
object,
uuid(2C22FAE4-2C04-11D4-AD0E-00C04F8DD0AC),
dual,
pointer_default (Unique)
]
interface IHComSensorAcqMgr: IDispatch
{
.
.
.
HRESULT ChangeSamMode(
[in] HESamMode eMode);
HRESULT AddMessageToQ(
[in] HESamSeqType eSeqType,
[in] HESamExecuteFreq eFreq,
[in] VARIANT_BOOL vbActive,
[in] HESamMode eMode
);
.
.
.
}
-
Nov 28th, 2000, 01:20 PM
#2
Hyperactive Member
Your idl is fine, and it makes no difference on a com call how many args it has ;-)
What makes you say it's failing because of that?
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 28th, 2000, 01:27 PM
#3
Hyperactive Member
According to your theory
AcqMgr.ChangeSamMode u
should work. Does it?
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 28th, 2000, 02:34 PM
#4
Thread Starter
New Member
ChangeSamMode method does work.
If I change the number of arguments the AddMessageToQ method uses from 4 to 1, it also will work.
When the AddMessageToQ has 4 arguments, I get a syntax error.
-
Nov 28th, 2000, 04:07 PM
#5
Hyperactive Member
but what is the syntax error?
td.
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
-
Nov 28th, 2000, 04:07 PM
#6
Thread Starter
New Member
I have the answer
My biggest thank you goes to Roger Butler from Anderson BDG who knew the answer immediately. His response was:
My initial examination of the syntax indicates that you should remove all parentheses as in:
AcqMgr.AddMessageToQ
KSamSeqTypeAlign,KSamExecRepeat6Hz,bActive,KSamModeAlignSummary
Parameters lists in VB only contain parentheses when a function returns a value as in :
retVal = AcqMgr.AddMessageToQ
(KSamSeqTypeAlign,KSamExecRepeat6Hz,bActive,KSamModeAlignSummary)
VB makes a distinction between void retVal functions (it calls them Subroutines) and retVal functions (it calls them Functions). Hence,
retval = MyCode (A,B,C) and MyCode A,B,C is the correct syntax depending on a retVal or not.
If you have become acustom to using parentheses to surround your parameter lists you can use the VB verb CALL as in:
CALL AcqMgr.AddMessageToQ
(KSamSeqTypeAlign,KSamExecRepeat6Hz,bActive,KSamModeAlignSummary)
Placing the verb CALL in front informs the VB compiler that you KNOW it's a Subroutine but you like to use parentheses and treat it as a Void Function.
This is not a standard practice. Go figure.
Hope this helps.
-
Nov 29th, 2000, 02:35 AM
#7
Hyperactive Member
"One logical slip and an entire scientific edifice comes tumbling down." - Robert M. Pirsig
[email protected]
"but if Einstein is right and God is in the details, reality requires that we sometimes get religion." - Scott Meyers.
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
|